diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index 6eba4dc3370d..5b503e4a5046 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -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 = @@ -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 @@ -1629,6 +1631,7 @@ function createSplitsAndOnyxData(participants, currentUserLogin, currentUserAcco undefined, category, tag, + billable, ); // STEP 4: Build optimistic reportActions. We need: @@ -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, @@ -1759,6 +1763,7 @@ function splitBill(participants, currentUserLogin, currentUserAccountID, amount, category, tag, existingSplitChatReportID, + billable, ); API.write( 'SplitBill', @@ -1771,6 +1776,7 @@ function splitBill(participants, currentUserLogin, currentUserAccountID, amount, category, merchant, tag, + billable, transactionID: splitData.transactionID, reportActionID: splitData.reportActionID, createdReportActionID: splitData.createdReportActionID, @@ -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', @@ -1809,6 +1816,7 @@ function splitBillAndOpenReport(participants, currentUserLogin, currentUserAccou comment, category, tag, + billable, transactionID: splitData.transactionID, reportActionID: splitData.reportActionID, createdReportActionID: splitData.createdReportActionID, @@ -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 = @@ -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 @@ -2075,6 +2085,7 @@ function startSplitBill(participants, currentUserLogin, currentUserAccountID, co category, tag, isFromGroupDM: !existingSplitChatReport, + billable, ...(existingSplitChatReport ? {} : {createdReportActionID: splitChatCreatedReportAction.reportActionID}), }, {optimisticData, successData, failureData}, diff --git a/src/pages/iou/SplitBillDetailsPage.js b/src/pages/iou/SplitBillDetailsPage.js index 885d0487edcb..be3afb822723 100644 --- a/src/pages/iou/SplitBillDetailsPage.js +++ b/src/pages/iou/SplitBillDetailsPage.js @@ -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( @@ -133,6 +134,7 @@ function SplitBillDetailsPage(props) { iouMerchant={splitMerchant} iouCategory={splitCategory} iouTag={splitTag} + iouIsBillable={splitBillable} iouType={CONST.IOU.TYPE.SPLIT} isReadOnly={!isEditingSplitBill} shouldShowSmartScanFields diff --git a/src/pages/iou/request/step/IOURequestStepConfirmation.js b/src/pages/iou/request/step/IOURequestStepConfirmation.js index 6028a735d132..0f1c2b27ad2e 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.js +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.js @@ -226,6 +226,7 @@ function IOURequestStepConfirmation({ transaction.tag, receiptFile, report.reportID, + transaction.billable, ); return; } @@ -244,6 +245,7 @@ function IOURequestStepConfirmation({ transaction.category, transaction.tag, report.reportID, + transaction.billable, ); return; } @@ -260,6 +262,7 @@ function IOURequestStepConfirmation({ transaction.merchant, transaction.category, transaction.tag, + transaction.billable, ); return; }