-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix optimistic merchant #32200
Fix optimistic merchant #32200
Changes from 7 commits
8a8ce84
b91478f
94f30d3
55eb7f3
b49a446
d4baf33
ec32acd
eb126a1
a1d15a9
6642c60
76569f5
1083e35
db14284
f179348
4708fed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -919,12 +919,13 @@ function requestMoney( | |||
* @param {Number} amount - always in the smallest unit of the currency | ||||
* @param {String} comment | ||||
* @param {String} currency | ||||
* @param {String} merchant | ||||
* @param {String} category | ||||
* @param {String} existingSplitChatReportID - the report ID where the split bill happens, could be a group chat or a workspace chat | ||||
* | ||||
* @return {Object} | ||||
*/ | ||||
function createSplitsAndOnyxData(participants, currentUserLogin, currentUserAccountID, amount, comment, currency, category, existingSplitChatReportID = '') { | ||||
function createSplitsAndOnyxData(participants, currentUserLogin, currentUserAccountID, amount, comment, currency, merchant, category, existingSplitChatReportID = '') { | ||||
dukenv0307 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||
const currentUserEmailForIOUSplit = OptionsListUtils.addSMSDomainIfPhoneNumber(currentUserLogin); | ||||
const participantAccountIDs = _.map(participants, (participant) => Number(participant.accountID)); | ||||
const existingSplitChatReport = | ||||
|
@@ -934,11 +935,6 @@ function createSplitsAndOnyxData(participants, currentUserLogin, currentUserAcco | |||
const splitChatReport = existingSplitChatReport || ReportUtils.buildOptimisticChatReport(participantAccountIDs); | ||||
const isOwnPolicyExpenseChat = splitChatReport.isOwnPolicyExpenseChat; | ||||
|
||||
// ReportID is -2 (aka "deleted") on the group transaction: https://github.com/Expensify/Auth/blob/3fa2698654cd4fbc30f9de38acfca3fbeb7842e4/auth/command/SplitTransaction.cpp#L24-L27 | ||||
const formattedParticipants = isOwnPolicyExpenseChat | ||||
? [currentUserLogin, ReportUtils.getReportName(splitChatReport)] | ||||
: Localize.arrayToString([currentUserLogin, ..._.map(participants, (participant) => participant.login || '')]); | ||||
|
||||
const splitTransaction = TransactionUtils.buildOptimisticTransaction( | ||||
amount, | ||||
currency, | ||||
|
@@ -947,7 +943,7 @@ function createSplitsAndOnyxData(participants, currentUserLogin, currentUserAcco | |||
'', | ||||
'', | ||||
'', | ||||
`${Localize.translateLocal('iou.splitBill')} ${Localize.translateLocal('common.with')} ${formattedParticipants} [${DateUtils.getDBTime().slice(0, 10)}]`, | ||||
merchant, | ||||
undefined, | ||||
undefined, | ||||
undefined, | ||||
|
@@ -1257,9 +1253,20 @@ function createSplitsAndOnyxData(participants, currentUserLogin, currentUserAcco | |||
* @param {String} currency | ||||
* @param {String} category | ||||
* @param {String} existingSplitChatReportID - Either a group DM or a workspace chat | ||||
* @param {String} merchant | ||||
*/ | ||||
function splitBill(participants, currentUserLogin, currentUserAccountID, amount, comment, currency, category, existingSplitChatReportID = '') { | ||||
const {splitData, splits, onyxData} = createSplitsAndOnyxData(participants, currentUserLogin, currentUserAccountID, amount, comment, currency, category, existingSplitChatReportID); | ||||
function splitBill(participants, currentUserLogin, currentUserAccountID, amount, comment, currency, category, existingSplitChatReportID = '', merchant) { | ||||
const {splitData, splits, onyxData} = createSplitsAndOnyxData( | ||||
participants, | ||||
currentUserLogin, | ||||
currentUserAccountID, | ||||
amount, | ||||
comment, | ||||
currency, | ||||
category, | ||||
existingSplitChatReportID, | ||||
merchant, | ||||
); | ||||
API.write( | ||||
'SplitBill', | ||||
{ | ||||
|
@@ -1290,9 +1297,10 @@ function splitBill(participants, currentUserLogin, currentUserAccountID, amount, | |||
* @param {String} comment | ||||
* @param {String} currency | ||||
* @param {String} category | ||||
* @param {String} merchant | ||||
*/ | ||||
function splitBillAndOpenReport(participants, currentUserLogin, currentUserAccountID, amount, comment, currency, category) { | ||||
const {splitData, splits, onyxData} = createSplitsAndOnyxData(participants, currentUserLogin, currentUserAccountID, amount, comment, currency, category); | ||||
function splitBillAndOpenReport(participants, currentUserLogin, currentUserAccountID, amount, comment, currency, category, merchant = '') { | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see that empty string is set as merchant default value here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I missed it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I confirmed it's redundant. Remove all default values App/src/libs/TransactionUtils.ts Line 43 in 48b5a29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated. |
||||
const {splitData, splits, onyxData} = createSplitsAndOnyxData(participants, currentUserLogin, currentUserAccountID, amount, comment, currency, category, '', merchant); | ||||
|
||||
API.write( | ||||
'SplitBillAndOpenReport', | ||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also reorder this