Skip to content

Commit

Permalink
Merge pull request Expensify#35125 from dukenv0307/fix/33763
Browse files Browse the repository at this point in the history
  • Loading branch information
francoisl authored Feb 1, 2024
2 parents c2083e3 + 9263a0f commit dc3c396
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/libs/actions/IOU.js
Original file line number Diff line number Diff line change
Expand Up @@ -1401,10 +1401,11 @@ function requestMoney(
* @param {String} category
* @param {String} tag
* @param {String} existingSplitChatReportID - the report ID where the split bill happens, could be a group chat or a workspace chat
* @param {Boolean} billable
*
* @return {Object}
*/
function createSplitsAndOnyxData(participants, currentUserLogin, currentUserAccountID, amount, comment, currency, merchant, category, tag, existingSplitChatReportID = '') {
function createSplitsAndOnyxData(participants, currentUserLogin, currentUserAccountID, amount, comment, currency, merchant, category, tag, existingSplitChatReportID = '', billable = false) {
const currentUserEmailForIOUSplit = OptionsListUtils.addSMSDomainIfPhoneNumber(currentUserLogin);
const participantAccountIDs = _.map(participants, (participant) => Number(participant.accountID));
const existingSplitChatReport =
Expand All @@ -1428,6 +1429,7 @@ function createSplitsAndOnyxData(participants, currentUserLogin, currentUserAcco
undefined,
category,
tag,
billable,
);

// Note: The created action must be optimistically generated before the IOU action so there's no chance that the created action appears after the IOU action in the chat
Expand Down Expand Up @@ -1629,6 +1631,7 @@ function createSplitsAndOnyxData(participants, currentUserLogin, currentUserAcco
undefined,
category,
tag,
billable,
);

// STEP 4: Build optimistic reportActions. We need:
Expand Down Expand Up @@ -1746,8 +1749,9 @@ function createSplitsAndOnyxData(participants, currentUserLogin, currentUserAcco
* @param {String} category
* @param {String} tag
* @param {String} existingSplitChatReportID - Either a group DM or a workspace chat
* @param {Boolean} billable
*/
function splitBill(participants, currentUserLogin, currentUserAccountID, amount, comment, currency, merchant, category, tag, existingSplitChatReportID = '') {
function splitBill(participants, currentUserLogin, currentUserAccountID, amount, comment, currency, merchant, category, tag, existingSplitChatReportID = '', billable = false) {
const {splitData, splits, onyxData} = createSplitsAndOnyxData(
participants,
currentUserLogin,
Expand All @@ -1759,6 +1763,7 @@ function splitBill(participants, currentUserLogin, currentUserAccountID, amount,
category,
tag,
existingSplitChatReportID,
billable,
);
API.write(
'SplitBill',
Expand All @@ -1771,6 +1776,7 @@ function splitBill(participants, currentUserLogin, currentUserAccountID, amount,
category,
merchant,
tag,
billable,
transactionID: splitData.transactionID,
reportActionID: splitData.reportActionID,
createdReportActionID: splitData.createdReportActionID,
Expand All @@ -1794,9 +1800,10 @@ function splitBill(participants, currentUserLogin, currentUserAccountID, amount,
* @param {String} merchant
* @param {String} category
* @param {String} tag
* @param {Boolean} billable
*/
function splitBillAndOpenReport(participants, currentUserLogin, currentUserAccountID, amount, comment, currency, merchant, category, tag) {
const {splitData, splits, onyxData} = createSplitsAndOnyxData(participants, currentUserLogin, currentUserAccountID, amount, comment, currency, merchant, category, tag);
function splitBillAndOpenReport(participants, currentUserLogin, currentUserAccountID, amount, comment, currency, merchant, category, tag, billable) {
const {splitData, splits, onyxData} = createSplitsAndOnyxData(participants, currentUserLogin, currentUserAccountID, amount, comment, currency, merchant, category, tag, billable);

API.write(
'SplitBillAndOpenReport',
Expand All @@ -1809,6 +1816,7 @@ function splitBillAndOpenReport(participants, currentUserLogin, currentUserAccou
comment,
category,
tag,
billable,
transactionID: splitData.transactionID,
reportActionID: splitData.reportActionID,
createdReportActionID: splitData.createdReportActionID,
Expand All @@ -1833,8 +1841,9 @@ function splitBillAndOpenReport(participants, currentUserLogin, currentUserAccou
* @param {String} tag
* @param {Object} receipt
* @param {String} existingSplitChatReportID - Either a group DM or a workspace chat
* @param {Boolean} billable
*/
function startSplitBill(participants, currentUserLogin, currentUserAccountID, comment, category, tag, receipt, existingSplitChatReportID = '') {
function startSplitBill(participants, currentUserLogin, currentUserAccountID, comment, category, tag, receipt, existingSplitChatReportID = '', billable = false) {
const currentUserEmailForIOUSplit = OptionsListUtils.addSMSDomainIfPhoneNumber(currentUserLogin);
const participantAccountIDs = _.map(participants, (participant) => Number(participant.accountID));
const existingSplitChatReport =
Expand Down Expand Up @@ -1862,6 +1871,7 @@ function startSplitBill(participants, currentUserLogin, currentUserAccountID, co
undefined,
category,
tag,
billable,
);

// Note: The created action must be optimistically generated before the IOU action so there's no chance that the created action appears after the IOU action in the chat
Expand Down Expand Up @@ -2075,6 +2085,7 @@ function startSplitBill(participants, currentUserLogin, currentUserAccountID, co
category,
tag,
isFromGroupDM: !existingSplitChatReport,
billable,
...(existingSplitChatReport ? {} : {createdReportActionID: splitChatCreatedReportAction.reportActionID}),
},
{optimisticData, successData, failureData},
Expand Down
2 changes: 2 additions & 0 deletions src/pages/iou/SplitBillDetailsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ function SplitBillDetailsPage(props) {
created: splitCreated,
category: splitCategory,
tag: splitTag,
billable: splitBillable,
} = isEditingSplitBill && props.draftTransaction ? ReportUtils.getTransactionDetails(props.draftTransaction) : ReportUtils.getTransactionDetails(props.transaction);

const onConfirm = useCallback(
Expand Down Expand Up @@ -133,6 +134,7 @@ function SplitBillDetailsPage(props) {
iouMerchant={splitMerchant}
iouCategory={splitCategory}
iouTag={splitTag}
iouIsBillable={splitBillable}
iouType={CONST.IOU.TYPE.SPLIT}
isReadOnly={!isEditingSplitBill}
shouldShowSmartScanFields
Expand Down
3 changes: 3 additions & 0 deletions src/pages/iou/request/step/IOURequestStepConfirmation.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ function IOURequestStepConfirmation({
transaction.tag,
receiptFile,
report.reportID,
transaction.billable,
);
return;
}
Expand All @@ -244,6 +245,7 @@ function IOURequestStepConfirmation({
transaction.category,
transaction.tag,
report.reportID,
transaction.billable,
);
return;
}
Expand All @@ -260,6 +262,7 @@ function IOURequestStepConfirmation({
transaction.merchant,
transaction.category,
transaction.tag,
transaction.billable,
);
return;
}
Expand Down

0 comments on commit dc3c396

Please sign in to comment.