From c9ef34fbefa2cb09036de1d37911059280d0d9fd Mon Sep 17 00:00:00 2001 From: Youssef Lourayad Date: Wed, 1 Nov 2023 20:48:48 +0400 Subject: [PATCH 01/18] Allow setting merchant for split bill --- src/libs/actions/IOU.js | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index 77ab246506ce..543e2ea1ec83 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -900,7 +900,7 @@ function requestMoney( * * @return {Object} */ -function createSplitsAndOnyxData(participants, currentUserLogin, currentUserAccountID, amount, comment, currency, category, existingSplitChatReportID = '') { +function createSplitsAndOnyxData(participants, currentUserLogin, currentUserAccountID, amount, comment, currency, merchant, category, existingSplitChatReportID = '') { const currentUserEmailForIOUSplit = OptionsListUtils.addSMSDomainIfPhoneNumber(currentUserLogin); const participantAccountIDs = _.map(participants, (participant) => Number(participant.accountID)); const existingSplitChatReport = @@ -923,7 +923,7 @@ function createSplitsAndOnyxData(participants, currentUserLogin, currentUserAcco '', '', '', - `${Localize.translateLocal('iou.splitBill')} ${Localize.translateLocal('common.with')} ${formattedParticipants} [${DateUtils.getDBTime().slice(0, 10)}]`, + merchant || Localize.translateLocal('iou.request'), undefined, undefined, undefined, @@ -1113,7 +1113,7 @@ function createSplitsAndOnyxData(participants, currentUserLogin, currentUserAcco '', CONST.IOU.TYPE.SPLIT, splitTransaction.transactionID, - undefined, + merchant || Localize.translateLocal('iou.request'), undefined, undefined, undefined, @@ -1234,8 +1234,18 @@ function createSplitsAndOnyxData(participants, currentUserLogin, currentUserAcco * @param {String} category * @param {String} existingSplitChatReportID - Either a group DM or a workspace chat */ -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, merchant, category, existingSplitChatReportID = '') { + const {splitData, splits, onyxData} = createSplitsAndOnyxData( + participants, + currentUserLogin, + currentUserAccountID, + amount, + comment, + currency, + merchant, + category, + existingSplitChatReportID, + ); API.write( 'SplitBill', { @@ -1267,8 +1277,8 @@ function splitBill(participants, currentUserLogin, currentUserAccountID, amount, * @param {String} currency * @param {String} category */ -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, merchant, category) { + const {splitData, splits, onyxData} = createSplitsAndOnyxData(participants, currentUserLogin, currentUserAccountID, amount, comment, currency, merchant, category); API.write( 'SplitBillAndOpenReport', @@ -1277,6 +1287,7 @@ function splitBillAndOpenReport(participants, currentUserLogin, currentUserAccou amount, splits: JSON.stringify(splits), currency, + merchant, comment, category, transactionID: splitData.transactionID, From ce5736382f44c68d3c8f8e4cd61fa964cfd3090a Mon Sep 17 00:00:00 2001 From: Youssef Lourayad Date: Fri, 3 Nov 2023 04:53:30 +0400 Subject: [PATCH 02/18] Style --- src/libs/actions/IOU.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index 543e2ea1ec83..def396cc9306 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -895,6 +895,7 @@ 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 * @@ -910,11 +911,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, @@ -1231,6 +1227,7 @@ function createSplitsAndOnyxData(participants, currentUserLogin, currentUserAcco * @param {Number} amount - always in smallest currency unit * @param {String} comment * @param {String} currency + * @param {String} merchant * @param {String} category * @param {String} existingSplitChatReportID - Either a group DM or a workspace chat */ @@ -1275,6 +1272,7 @@ function splitBill(participants, currentUserLogin, currentUserAccountID, amount, * @param {Number} amount - always in smallest currency unit * @param {String} comment * @param {String} currency + * @param {String} merchant * @param {String} category */ function splitBillAndOpenReport(participants, currentUserLogin, currentUserAccountID, amount, comment, currency, merchant, category) { From 41991a4015f622c942e5abec0c53a0af6650d347 Mon Sep 17 00:00:00 2001 From: Youssef Lourayad Date: Fri, 3 Nov 2023 22:37:35 +0400 Subject: [PATCH 03/18] Fix test --- tests/actions/IOUTest.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/actions/IOUTest.js b/tests/actions/IOUTest.js index 2c6b94a2d7d5..866a41c0101d 100644 --- a/tests/actions/IOUTest.js +++ b/tests/actions/IOUTest.js @@ -806,6 +806,7 @@ describe('actions/IOU', () => { */ const amount = 400; const comment = 'Yes, I am splitting a bill for $4 USD'; + const merchant = 'Yema Kitchen'; let carlosChatReport = { reportID: NumberUtils.rand64(), type: CONST.REPORT.TYPE.CHAT, @@ -924,6 +925,7 @@ describe('actions/IOU', () => { amount, comment, CONST.CURRENCY.USD, + merchant, ); return waitForBatchedUpdates(); }) @@ -1104,12 +1106,10 @@ describe('actions/IOU', () => { expect(vitTransaction.comment.comment).toBe(comment); expect(groupTransaction.comment.comment).toBe(comment); - expect(carlosTransaction.merchant).toBe(CONST.TRANSACTION.DEFAULT_MERCHANT); - expect(julesTransaction.merchant).toBe(CONST.TRANSACTION.DEFAULT_MERCHANT); - expect(vitTransaction.merchant).toBe(CONST.TRANSACTION.DEFAULT_MERCHANT); - expect(groupTransaction.merchant).toBe( - `Split bill with ${RORY_EMAIL}, ${CARLOS_EMAIL}, ${JULES_EMAIL}, and ${VIT_EMAIL} [${DateUtils.getDBTime().slice(0, 10)}]`, - ); + expect(carlosTransaction.merchant).toBe(merchant); + expect(julesTransaction.merchant).toBe(merchant); + expect(vitTransaction.merchant).toBe(merchant); + expect(groupTransaction.merchant).toBe(merchant); expect(carlosTransaction.comment.source).toBe(CONST.IOU.TYPE.SPLIT); expect(julesTransaction.comment.source).toBe(CONST.IOU.TYPE.SPLIT); From 0667951b2480106ac5f712aab8ef296cfe05fa45 Mon Sep 17 00:00:00 2001 From: Youssef Lourayad Date: Tue, 14 Nov 2023 22:05:34 +0100 Subject: [PATCH 04/18] Fix merchant param missing --- .../ReportActionItem/MoneyRequestPreview.js | 22 +++++++------------ .../iou/steps/MoneyRequestConfirmPage.js | 3 ++- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestPreview.js b/src/components/ReportActionItem/MoneyRequestPreview.js index aa9d9d5c0070..020ab66719ca 100644 --- a/src/components/ReportActionItem/MoneyRequestPreview.js +++ b/src/components/ReportActionItem/MoneyRequestPreview.js @@ -168,9 +168,8 @@ function MoneyRequestPreview(props) { const isDeleted = lodashGet(props.action, 'pendingAction', null) === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE; // Show the merchant for IOUs and expenses only if they are custom or not related to scanning smartscan - const shouldShowMerchant = - !_.isEmpty(requestMerchant) && !props.isBillSplit && requestMerchant !== CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT && requestMerchant !== CONST.TRANSACTION.DEFAULT_MERCHANT; - const shouldShowDescription = !_.isEmpty(description) && !shouldShowMerchant; + const shouldShowMerchant = !_.isEmpty(requestMerchant) && requestMerchant !== CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT && requestMerchant !== CONST.TRANSACTION.DEFAULT_MERCHANT; + const merchantOrDescription = shouldShowMerchant ? requestMerchant : description || ''; const receiptImages = hasReceipt ? [ReceiptUtils.getThumbnailAndImageURIs(props.transaction)] : []; @@ -320,19 +319,14 @@ function MoneyRequestPreview(props) { )} - {shouldShowMerchant && ( - - - {hasPendingWaypoints ? requestMerchant.replace(CONST.REGEX.FIRST_SPACE, props.translate('common.tbd')) : requestMerchant} - - - )} - {!isCurrentUserManager && props.shouldShowPendingConversionMessage && ( - {props.translate('iou.pendingConversionMessage')} - )} - {shouldShowDescription && {description}} + <> + {merchantOrDescription && {merchantOrDescription}} + {!isCurrentUserManager && props.shouldShowPendingConversionMessage && ( + {props.translate('iou.pendingConversionMessage')} + )} + {props.isBillSplit && !_.isEmpty(participantAccountIDs) && requestAmount > 0 && ( diff --git a/src/pages/iou/steps/MoneyRequestConfirmPage.js b/src/pages/iou/steps/MoneyRequestConfirmPage.js index 54a84f99fa55..2ecaf6da19bb 100644 --- a/src/pages/iou/steps/MoneyRequestConfirmPage.js +++ b/src/pages/iou/steps/MoneyRequestConfirmPage.js @@ -190,7 +190,6 @@ function MoneyRequestConfirmPage(props) { /** * @param {Array} selectedParticipants - * @param {String} trimmedComment */ const createDistanceRequest = useCallback( (selectedParticipants, trimmedComment) => { @@ -242,6 +241,7 @@ function MoneyRequestConfirmPage(props) { props.iou.amount, trimmedComment, props.iou.currency, + props.iou.merchant, props.iou.category, reportID, ); @@ -257,6 +257,7 @@ function MoneyRequestConfirmPage(props) { props.iou.amount, trimmedComment, props.iou.currency, + props.iou.merchant, props.iou.category, ); return; From 1466ce78bc3a1b0614fc8304d5123639cf80eba5 Mon Sep 17 00:00:00 2001 From: Youssef Lourayad Date: Tue, 14 Nov 2023 22:09:19 +0100 Subject: [PATCH 05/18] Lint --- src/pages/iou/steps/MoneyRequestConfirmPage.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/iou/steps/MoneyRequestConfirmPage.js b/src/pages/iou/steps/MoneyRequestConfirmPage.js index 2ecaf6da19bb..88d25de18691 100644 --- a/src/pages/iou/steps/MoneyRequestConfirmPage.js +++ b/src/pages/iou/steps/MoneyRequestConfirmPage.js @@ -281,6 +281,7 @@ function MoneyRequestConfirmPage(props) { props.currentUserPersonalDetails.login, props.currentUserPersonalDetails.accountID, props.iou.currency, + props.iou.merchant, props.iou.category, props.iou.receiptPath, props.iou.receiptFilename, From 8b91ea7e9d5748c11f36f0a01e8fd52a2457fe64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Ch=C3=A1vez?= Date: Wed, 22 Nov 2023 10:30:11 -0600 Subject: [PATCH 06/18] Remove isBillSplit condition for showing merchant --- src/components/ReportActionItem/MoneyRequestPreview.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ReportActionItem/MoneyRequestPreview.js b/src/components/ReportActionItem/MoneyRequestPreview.js index 1bfe5978b615..df5db01ed0a9 100644 --- a/src/components/ReportActionItem/MoneyRequestPreview.js +++ b/src/components/ReportActionItem/MoneyRequestPreview.js @@ -171,7 +171,7 @@ function MoneyRequestPreview(props) { // Show the merchant for IOUs and expenses only if they are custom or not related to scanning smartscan const shouldShowMerchant = - !_.isEmpty(requestMerchant) && !props.isBillSplit && requestMerchant !== CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT && requestMerchant !== CONST.TRANSACTION.DEFAULT_MERCHANT; + !_.isEmpty(requestMerchant) && requestMerchant !== CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT && requestMerchant !== CONST.TRANSACTION.DEFAULT_MERCHANT; const shouldShowMerchantOrDescription = !isScanning && (!_.isEmpty(description) || shouldShowMerchant); const merchantOrDescription = shouldShowMerchant ? requestMerchant : description || ''; From b72d665ada12ee50d706a461a2d459634820aac9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Ch=C3=A1vez?= Date: Wed, 22 Nov 2023 10:30:54 -0600 Subject: [PATCH 07/18] Fix lint error --- src/components/ReportActionItem/MoneyRequestPreview.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestPreview.js b/src/components/ReportActionItem/MoneyRequestPreview.js index df5db01ed0a9..28e43304e35f 100644 --- a/src/components/ReportActionItem/MoneyRequestPreview.js +++ b/src/components/ReportActionItem/MoneyRequestPreview.js @@ -170,12 +170,10 @@ function MoneyRequestPreview(props) { const isDeleted = lodashGet(props.action, 'pendingAction', null) === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE; // Show the merchant for IOUs and expenses only if they are custom or not related to scanning smartscan - const shouldShowMerchant = - !_.isEmpty(requestMerchant) && requestMerchant !== CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT && requestMerchant !== CONST.TRANSACTION.DEFAULT_MERCHANT; + const shouldShowMerchant = !_.isEmpty(requestMerchant) && requestMerchant !== CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT && requestMerchant !== CONST.TRANSACTION.DEFAULT_MERCHANT; const shouldShowMerchantOrDescription = !isScanning && (!_.isEmpty(description) || shouldShowMerchant); const merchantOrDescription = shouldShowMerchant ? requestMerchant : description || ''; - const receiptImages = hasReceipt ? [ReceiptUtils.getThumbnailAndImageURIs(props.transaction)] : []; const hasPendingWaypoints = lodashGet(props.transaction, 'pendingFields.waypoints', null); From 88e6d92d4dcdf95628b2f6df5e2931ba13d375cc Mon Sep 17 00:00:00 2001 From: Youssef Lourayad Date: Thu, 7 Dec 2023 16:48:35 +0100 Subject: [PATCH 08/18] Lint --- .../ReportActionItem/MoneyRequestPreview.js | 18 +++++++++--------- src/libs/actions/IOU.js | 2 -- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestPreview.js b/src/components/ReportActionItem/MoneyRequestPreview.js index d8244a6f3eff..ae2f02af5c62 100644 --- a/src/components/ReportActionItem/MoneyRequestPreview.js +++ b/src/components/ReportActionItem/MoneyRequestPreview.js @@ -173,15 +173,15 @@ function MoneyRequestPreview(props) { const shouldShowMerchant = !_.isEmpty(requestMerchant) && requestMerchant !== CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT && requestMerchant !== CONST.TRANSACTION.DEFAULT_MERCHANT; const shouldShowDescription = !_.isEmpty(description) && !shouldShowMerchant && !isScanning; const hasPendingWaypoints = lodashGet(props.transaction, 'pendingFields.waypoints', null); - const merchantOrDescription = useMemo(() => { - if (!shouldShowMerchant) { - return description || ''; - } - if (hasPendingWaypoints) { - return requestMerchant.replace(CONST.REGEX.FIRST_SPACE, props.translate('common.tbd')); - } - return requestMerchant; - }); + + let merchantOrDescription = ''; + if (!shouldShowMerchant) { + merchantOrDescription = description || ''; + } else if (hasPendingWaypoints) { + merchantOrDescription = requestMerchant.replace(CONST.REGEX.FIRST_SPACE, props.translate('common.tbd')); + } else { + merchantOrDescription = requestMerchant; + } const receiptImages = hasReceipt ? [ReceiptUtils.getThumbnailAndImageURIs(props.transaction)] : []; diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index 3039b0e945d7..5215e5efc905 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -883,7 +883,6 @@ 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 {String} merchant * * @return {Object} */ @@ -1219,7 +1218,6 @@ function createSplitsAndOnyxData(participants, currentUserLogin, currentUserAcco * @param {String} category * @param {String} tag * @param {String} existingSplitChatReportID - Either a group DM or a workspace chat - * @param {String} merchant */ function splitBill(participants, currentUserLogin, currentUserAccountID, amount, comment, currency, merchant, category, tag, existingSplitChatReportID = '') { const {splitData, splits, onyxData} = createSplitsAndOnyxData( From e40b8c2f96986e1d00929a9610351673c03a44f7 Mon Sep 17 00:00:00 2001 From: Youssef Lourayad Date: Mon, 11 Dec 2023 14:53:00 +0100 Subject: [PATCH 09/18] Lint --- src/pages/iou/steps/MoneyRequestConfirmPage.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/iou/steps/MoneyRequestConfirmPage.js b/src/pages/iou/steps/MoneyRequestConfirmPage.js index 0948ae5ce38c..b60b899d846e 100644 --- a/src/pages/iou/steps/MoneyRequestConfirmPage.js +++ b/src/pages/iou/steps/MoneyRequestConfirmPage.js @@ -285,7 +285,6 @@ function MoneyRequestConfirmPage(props) { receiptFile, iouType, reportID, - props.iou.merchant, ], ); From 7772411d603c3e27689b32d6c59eacee3b446319 Mon Sep 17 00:00:00 2001 From: Youssef Lourayad Date: Mon, 11 Dec 2023 21:40:27 +0100 Subject: [PATCH 10/18] Fix merchant being displayed in scanned requests --- ...oneyTemporaryForRefactorRequestConfirmationList.js | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js b/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js index e622367cd6f9..f18196f03552 100755 --- a/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js +++ b/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js @@ -140,9 +140,6 @@ const propTypes = { /** Whether the money request is a distance request */ isDistanceRequest: PropTypes.bool, - /** Whether the money request is a scan request */ - isScanRequest: PropTypes.bool, - /** Whether we're editing a split bill */ isEditingSplitBill: PropTypes.bool, @@ -215,7 +212,6 @@ function MoneyTemporaryForRefactorRequestConfirmationList({ isEditingSplitBill, isPolicyExpenseChat, isReadOnly, - isScanRequest, listStyles, mileageRate, onConfirm, @@ -244,8 +240,6 @@ function MoneyTemporaryForRefactorRequestConfirmationList({ const isTypeSplit = iouType === CONST.IOU.TYPE.SPLIT; const isTypeSend = iouType === CONST.IOU.TYPE.SEND; - const isSplitWithScan = isTypeSplit && isScanRequest; - const {unit, rate, currency} = mileageRate; const distance = lodashGet(transaction, 'routes.route0.distance', 0); const shouldCalculateDistanceAmount = isDistanceRequest && iouAmount === 0; @@ -259,9 +253,8 @@ function MoneyTemporaryForRefactorRequestConfirmationList({ // Do not hide fields in case of send money request const shouldShowAllFields = isDistanceRequest || shouldExpandFields || !shouldShowSmartScanFields || isTypeSend || isEditingSplitBill; - // In Send Money flow, we don't allow the Merchant or Date to be edited. For distance requests, don't show the merchant as there's already another "Distance" menu item - const shouldShowDate = shouldShowAllFields && !isTypeSend && !isSplitWithScan; - const shouldShowMerchant = shouldShowAllFields && !isTypeSend && !isDistanceRequest && !isSplitWithScan; + const shouldShowDate = shouldShowSmartScanFields || isDistanceRequest; + const shouldShowMerchant = shouldShowSmartScanFields && !isDistanceRequest; // Fetches the first tag list of the policy const policyTag = PolicyUtils.getTag(policyTags); From d2bc873d66979292e750521b16acd1bdb845768f Mon Sep 17 00:00:00 2001 From: Youssef Lourayad Date: Mon, 11 Dec 2023 21:50:13 +0100 Subject: [PATCH 11/18] Copy the updates to the new component --- src/pages/iou/request/step/IOURequestStepConfirmation.js | 2 ++ src/pages/iou/steps/MoneyRequestConfirmPage.js | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepConfirmation.js b/src/pages/iou/request/step/IOURequestStepConfirmation.js index 81c153cb2320..3b99b7c0ee55 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.js +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.js @@ -207,6 +207,7 @@ function IOURequestStepConfirmation({ transaction.amount, trimmedComment, transaction.currency, + transaction.merchant, transaction.category, report.reportID, ); @@ -222,6 +223,7 @@ function IOURequestStepConfirmation({ transaction.amount, trimmedComment, transaction.currency, + transaction.merchant, transaction.category, ); return; diff --git a/src/pages/iou/steps/MoneyRequestConfirmPage.js b/src/pages/iou/steps/MoneyRequestConfirmPage.js index b60b899d846e..d6000e4e48cc 100644 --- a/src/pages/iou/steps/MoneyRequestConfirmPage.js +++ b/src/pages/iou/steps/MoneyRequestConfirmPage.js @@ -181,6 +181,7 @@ function MoneyRequestConfirmPage(props) { /** * @param {Array} selectedParticipants + * @param {String} trimmedComment */ const createDistanceRequest = useCallback( (selectedParticipants, trimmedComment) => { @@ -232,10 +233,10 @@ function MoneyRequestConfirmPage(props) { props.iou.amount, trimmedComment, props.iou.currency, - props.iou.merchant, props.iou.category, props.iou.tag, reportID, + props.iou.merchant, ); return; } @@ -249,9 +250,9 @@ function MoneyRequestConfirmPage(props) { props.iou.amount, trimmedComment, props.iou.currency, - props.iou.merchant, props.iou.category, props.iou.tag, + props.iou.merchant, ); return; } @@ -274,7 +275,6 @@ function MoneyRequestConfirmPage(props) { props.currentUserPersonalDetails.login, props.currentUserPersonalDetails.accountID, props.iou.currency, - props.iou.merchant, props.iou.category, props.iou.tag, props.iou.receiptPath, @@ -285,6 +285,7 @@ function MoneyRequestConfirmPage(props) { receiptFile, iouType, reportID, + props.iou.merchant, ], ); From 54330f08d23faae5f7e7bf92a630f065d6cc61fd Mon Sep 17 00:00:00 2001 From: Youssef Lourayad Date: Mon, 11 Dec 2023 21:50:59 +0100 Subject: [PATCH 12/18] Remove duplicate param --- src/libs/actions/IOU.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index 25bcdd26043c..6b90e2da9620 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -1383,7 +1383,6 @@ function splitBill(participants, currentUserLogin, currentUserAccountID, amount, currency, merchant, category, - category, tag, existingSplitChatReportID, ); From 4dd99d79e48376e379c1e7525b57f9c32ed909a5 Mon Sep 17 00:00:00 2001 From: Youssef Lourayad Date: Mon, 11 Dec 2023 22:03:57 +0100 Subject: [PATCH 13/18] Add missing fields to split bill actions --- src/libs/actions/IOU.js | 10 +++++++++- .../iou/request/step/IOURequestStepConfirmation.js | 13 ++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index 6b90e2da9620..33428ba4de89 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -1455,10 +1455,12 @@ function splitBillAndOpenReport(participants, currentUserLogin, currentUserAccou * @param {String} currentUserLogin * @param {Number} currentUserAccountID * @param {String} comment + * @param {String} category + * @param {String} tag * @param {Object} receipt * @param {String} existingSplitChatReportID - Either a group DM or a workspace chat */ -function startSplitBill(participants, currentUserLogin, currentUserAccountID, comment, receipt, existingSplitChatReportID = '') { +function startSplitBill(participants, currentUserLogin, currentUserAccountID, comment, category, tag, receipt, existingSplitChatReportID = '') { const currentUserEmailForIOUSplit = OptionsListUtils.addSMSDomainIfPhoneNumber(currentUserLogin); const participantAccountIDs = _.map(participants, (participant) => Number(participant.accountID)); const existingSplitChatReport = @@ -1667,6 +1669,8 @@ function startSplitBill(participants, currentUserLogin, currentUserAccountID, co splits: JSON.stringify(splits), receipt, comment, + category, + tag, isFromGroupDM: !existingSplitChatReport, ...(existingSplitChatReport ? {} : {createdReportActionID: splitChatCreatedReportAction.reportActionID}), }, @@ -1874,6 +1878,8 @@ function completeSplitBill(chatReportID, reportAction, updatedTransaction, sessi created: transactionCreated, merchant: transactionMerchant, comment: transactionComment, + category: transactionCategory, + tag: transactionTag, } = ReportUtils.getTransactionDetails(updatedTransaction); API.write( @@ -1885,6 +1891,8 @@ function completeSplitBill(chatReportID, reportAction, updatedTransaction, sessi created: transactionCreated, merchant: transactionMerchant, comment: transactionComment, + category: transactionCategory, + tag: transactionTag, splits: JSON.stringify(splits), }, {optimisticData, successData, failureData}, diff --git a/src/pages/iou/request/step/IOURequestStepConfirmation.js b/src/pages/iou/request/step/IOURequestStepConfirmation.js index 3b99b7c0ee55..0c692797457a 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.js +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.js @@ -193,7 +193,16 @@ function IOURequestStepConfirmation({ // If we have a receipt let's start the split bill by creating only the action, the transaction, and the group DM if needed if (iouType === CONST.IOU.TYPE.SPLIT && receiptFile) { const existingSplitChatReportID = CONST.REGEX.NUMBER.test(reportID) ? reportID : ''; - IOU.startSplitBill(selectedParticipants, currentUserPersonalDetails.login, currentUserPersonalDetails.accountID, trimmedComment, receiptFile, existingSplitChatReportID); + IOU.startSplitBill( + selectedParticipants, + currentUserPersonalDetails.login, + currentUserPersonalDetails.accountID, + trimmedComment, + transaction.category, + transaction.tag, + receiptFile, + existingSplitChatReportID, + ); return; } @@ -209,6 +218,7 @@ function IOURequestStepConfirmation({ transaction.currency, transaction.merchant, transaction.category, + transaction.tag, report.reportID, ); return; @@ -225,6 +235,7 @@ function IOURequestStepConfirmation({ transaction.currency, transaction.merchant, transaction.category, + transaction.tag, ); return; } From ac6ef28ecd4cb76ff60caa9707ba93c0416de8df Mon Sep 17 00:00:00 2001 From: Youssef Lourayad Date: Wed, 13 Dec 2023 04:43:58 +0100 Subject: [PATCH 14/18] Address PR comments --- .../MoneyTemporaryForRefactorRequestConfirmationList.js | 1 - src/components/ReportActionItem/MoneyRequestPreview.js | 4 +--- src/pages/iou/request/step/IOURequestStepConfirmation.js | 1 - src/pages/iou/steps/MoneyRequestConfirmPage.js | 2 -- 4 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js b/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js index 61890f8908e9..6282f7ca0f25 100755 --- a/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js +++ b/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js @@ -188,7 +188,6 @@ const defaultProps = { transaction: {}, mileageRate: {unit: CONST.CUSTOM_UNITS.DISTANCE_UNIT_MILES, rate: 0, currency: 'USD'}, isDistanceRequest: false, - isScanRequest: false, shouldShowSmartScanFields: true, isPolicyExpenseChat: false, }; diff --git a/src/components/ReportActionItem/MoneyRequestPreview.js b/src/components/ReportActionItem/MoneyRequestPreview.js index 7060cc1c97b9..2e6d032add24 100644 --- a/src/components/ReportActionItem/MoneyRequestPreview.js +++ b/src/components/ReportActionItem/MoneyRequestPreview.js @@ -174,13 +174,11 @@ function MoneyRequestPreview(props) { const shouldShowDescription = !_.isEmpty(description) && !shouldShowMerchant && !isScanning; const hasPendingWaypoints = lodashGet(props.transaction, 'pendingFields.waypoints', null); - let merchantOrDescription = ''; + let merchantOrDescription = requestMerchant; if (!shouldShowMerchant) { merchantOrDescription = description || ''; } else if (hasPendingWaypoints) { merchantOrDescription = requestMerchant.replace(CONST.REGEX.FIRST_SPACE, props.translate('common.tbd')); - } else { - merchantOrDescription = requestMerchant; } const receiptImages = hasReceipt ? [ReceiptUtils.getThumbnailAndImageURIs(props.transaction)] : []; diff --git a/src/pages/iou/request/step/IOURequestStepConfirmation.js b/src/pages/iou/request/step/IOURequestStepConfirmation.js index 63cbf6a87ec5..a2228bdd190c 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.js +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.js @@ -350,7 +350,6 @@ function IOURequestStepConfirmation({ bankAccountRoute={ReportUtils.getBankAccountRoute(report)} iouMerchant={transaction.merchant} iouCreated={transaction.created} - isScanRequest={requestType === CONST.IOU.REQUEST_TYPE.SCAN} isDistanceRequest={requestType === CONST.IOU.REQUEST_TYPE.DISTANCE} shouldShowSmartScanFields={_.isEmpty(lodashGet(transaction, 'receipt.source', ''))} /> diff --git a/src/pages/iou/steps/MoneyRequestConfirmPage.js b/src/pages/iou/steps/MoneyRequestConfirmPage.js index 03ebb9bdb562..9d049bed9a67 100644 --- a/src/pages/iou/steps/MoneyRequestConfirmPage.js +++ b/src/pages/iou/steps/MoneyRequestConfirmPage.js @@ -64,7 +64,6 @@ function MoneyRequestConfirmPage(props) { const iouType = useInitialValue(() => lodashGet(props.route, 'params.iouType', '')); const reportID = useInitialValue(() => lodashGet(props.route, 'params.reportID', '')); const isDistanceRequest = MoneyRequestUtils.isDistanceRequest(iouType, props.selectedTab); - const isScanRequest = MoneyRequestUtils.isScanRequest(props.selectedTab); const [receiptFile, setReceiptFile] = useState(); const personalDetails = usePersonalDetails() || CONST.EMPTY_OBJECT; @@ -389,7 +388,6 @@ function MoneyRequestConfirmPage(props) { bankAccountRoute={ReportUtils.getBankAccountRoute(props.report)} iouMerchant={props.iou.merchant} iouCreated={props.iou.created} - isScanRequest={isScanRequest} isDistanceRequest={isDistanceRequest} shouldShowSmartScanFields={_.isEmpty(props.iou.receiptPath)} /> From b8924308a85be411725fb98a1a8d7266984a134d Mon Sep 17 00:00:00 2001 From: Youssef Lourayad Date: Wed, 13 Dec 2023 18:24:55 +0100 Subject: [PATCH 15/18] Revert changes made to deprecated component --- src/pages/iou/steps/MoneyRequestConfirmPage.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pages/iou/steps/MoneyRequestConfirmPage.js b/src/pages/iou/steps/MoneyRequestConfirmPage.js index 9d049bed9a67..03ebb9bdb562 100644 --- a/src/pages/iou/steps/MoneyRequestConfirmPage.js +++ b/src/pages/iou/steps/MoneyRequestConfirmPage.js @@ -64,6 +64,7 @@ function MoneyRequestConfirmPage(props) { const iouType = useInitialValue(() => lodashGet(props.route, 'params.iouType', '')); const reportID = useInitialValue(() => lodashGet(props.route, 'params.reportID', '')); const isDistanceRequest = MoneyRequestUtils.isDistanceRequest(iouType, props.selectedTab); + const isScanRequest = MoneyRequestUtils.isScanRequest(props.selectedTab); const [receiptFile, setReceiptFile] = useState(); const personalDetails = usePersonalDetails() || CONST.EMPTY_OBJECT; @@ -388,6 +389,7 @@ function MoneyRequestConfirmPage(props) { bankAccountRoute={ReportUtils.getBankAccountRoute(props.report)} iouMerchant={props.iou.merchant} iouCreated={props.iou.created} + isScanRequest={isScanRequest} isDistanceRequest={isDistanceRequest} shouldShowSmartScanFields={_.isEmpty(props.iou.receiptPath)} /> From b716519f1baa7db80eb50d5adb0feef308b74749 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Ch=C3=A1vez?= Date: Thu, 14 Dec 2023 12:11:35 -0600 Subject: [PATCH 16/18] Fix missing props validation for translate function --- src/components/ReportActionItem/MoneyRequestPreview.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ReportActionItem/MoneyRequestPreview.js b/src/components/ReportActionItem/MoneyRequestPreview.js index aeaf9f0ecb09..00dea35577a6 100644 --- a/src/components/ReportActionItem/MoneyRequestPreview.js +++ b/src/components/ReportActionItem/MoneyRequestPreview.js @@ -170,7 +170,7 @@ function MoneyRequestPreview(props) { if (!shouldShowMerchant) { merchantOrDescription = description || ''; } else if (hasPendingWaypoints) { - merchantOrDescription = requestMerchant.replace(CONST.REGEX.FIRST_SPACE, props.translate('common.tbd')); + merchantOrDescription = requestMerchant.replace(CONST.REGEX.FIRST_SPACE, translate('common.tbd')); } const receiptImages = hasReceipt ? [ReceiptUtils.getThumbnailAndImageURIs(props.transaction)] : []; From 83e74bf08be21aad8350301ffaeaf7e4e5001943 Mon Sep 17 00:00:00 2001 From: Youssef Lourayad Date: Tue, 19 Dec 2023 09:50:18 +0100 Subject: [PATCH 17/18] Remove redundant prop --- src/pages/iou/request/step/IOURequestStepConfirmation.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/iou/request/step/IOURequestStepConfirmation.js b/src/pages/iou/request/step/IOURequestStepConfirmation.js index c9ce6dbb0289..7ba4f635ff01 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.js +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.js @@ -225,7 +225,6 @@ function IOURequestStepConfirmation({ transaction.category, transaction.tag, report.reportID, - transaction.merchant, ); return; } From 6526dda2a324b9c637b2235d59738a8e12805d81 Mon Sep 17 00:00:00 2001 From: Youssef Lourayad Date: Tue, 19 Dec 2023 19:42:43 +0100 Subject: [PATCH 18/18] Update text style of merchant and change positions --- src/components/ReportActionItem/MoneyRequestPreview.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ReportActionItem/MoneyRequestPreview.js b/src/components/ReportActionItem/MoneyRequestPreview.js index 00dea35577a6..35859914016d 100644 --- a/src/components/ReportActionItem/MoneyRequestPreview.js +++ b/src/components/ReportActionItem/MoneyRequestPreview.js @@ -323,10 +323,10 @@ function MoneyRequestPreview(props) { - {(shouldShowDescription || shouldShowMerchant) && {merchantOrDescription}} {!isCurrentUserManager && props.shouldShowPendingConversionMessage && ( {translate('iou.pendingConversionMessage')} )} + {(shouldShowDescription || shouldShowMerchant) && {merchantOrDescription}} {props.isBillSplit && !_.isEmpty(participantAccountIDs) && requestAmount > 0 && (