From f319d0e6485b5b5d1b4327b799e4baafb5218508 Mon Sep 17 00:00:00 2001 From: "marta.sudol" Date: Thu, 10 Jul 2025 13:45:54 +0200 Subject: [PATCH 01/12] perf: getBankAccountRoute usage optimization --- src/components/KYCWall/BaseKYCWall.tsx | 9 +++++---- src/components/KYCWall/types.ts | 4 ++-- src/components/MoneyReportHeader.tsx | 7 ++----- src/components/MoneyRequestConfirmationList.tsx | 12 ++++++------ .../MoneyRequestReportPreviewContent.tsx | 4 +--- src/components/SettlementButton/index.tsx | 4 +--- src/components/SettlementButton/types.ts | 4 ++-- src/hooks/usePaymentOptions.ts | 13 +++++++++---- src/pages/home/report/PureReportActionItem.tsx | 2 +- src/pages/iou/MoneyRequestAmountForm.tsx | 10 +++++----- src/pages/iou/request/step/IOURequestStepAmount.tsx | 2 +- .../iou/request/step/IOURequestStepConfirmation.tsx | 2 +- src/pages/settings/Wallet/WalletPage/WalletPage.tsx | 2 +- 13 files changed, 37 insertions(+), 38 deletions(-) diff --git a/src/components/KYCWall/BaseKYCWall.tsx b/src/components/KYCWall/BaseKYCWall.tsx index 7f399546ad9d..687970c91564 100644 --- a/src/components/KYCWall/BaseKYCWall.tsx +++ b/src/components/KYCWall/BaseKYCWall.tsx @@ -10,7 +10,7 @@ import getClickedTargetLocation from '@libs/getClickedTargetLocation'; import Log from '@libs/Log'; import Navigation from '@libs/Navigation/Navigation'; import {hasExpensifyPaymentMethod} from '@libs/PaymentUtils'; -import {isExpenseReport as isExpenseReportReportUtils, isIOUReport} from '@libs/ReportUtils'; +import {getBankAccountRoute, isExpenseReport as isExpenseReportReportUtils, isIOUReport} from '@libs/ReportUtils'; import {kycWallRef} from '@userActions/PaymentMethods'; import {createWorkspaceFromIOUPayment} from '@userActions/Policy/Policy'; import {setKYCWallSource} from '@userActions/Wallet'; @@ -30,7 +30,7 @@ const POPOVER_MENU_ANCHOR_POSITION_HORIZONTAL_OFFSET = 20; // before continuing to take whatever action they originally intended to take. It requires a button as a child and a native event so we can get the coordinates and use it // to render the AddPaymentMethodMenu in the correct location. function KYCWall({ - addBankAccountRoute, + chatReport, addDebitCardRoute, anchorAlignment = { horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.LEFT, @@ -122,10 +122,11 @@ function KYCWall({ return; } - Navigation.navigate(addBankAccountRoute); + const bankAccountRoute = getBankAccountRoute(chatReport); + Navigation.navigate(bankAccountRoute); } }, - [addBankAccountRoute, addDebitCardRoute, iouReport, onSelectPaymentMethod], + [chatReport, addDebitCardRoute, iouReport, onSelectPaymentMethod], ); /** diff --git a/src/components/KYCWall/types.ts b/src/components/KYCWall/types.ts index 5214e5ea15b9..024212306f62 100644 --- a/src/components/KYCWall/types.ts +++ b/src/components/KYCWall/types.ts @@ -22,8 +22,8 @@ type AnchorPosition = { type PaymentMethod = ValueOf; type KYCWallProps = { - /** Route for the Add Bank Account screen for a given navigation stack */ - addBankAccountRoute: Route; + /** Chat report for calculating bank account routes */ + chatReport?: OnyxEntry; /** Route for the Add Debit Card screen for a given navigation stack */ addDebitCardRoute?: Route; diff --git a/src/components/MoneyReportHeader.tsx b/src/components/MoneyReportHeader.tsx index b44ba1b38a05..d0909247262b 100644 --- a/src/components/MoneyReportHeader.tsx +++ b/src/components/MoneyReportHeader.tsx @@ -30,7 +30,6 @@ import {getSecondaryReportActions} from '@libs/ReportSecondaryActionUtils'; import { changeMoneyRequestHoldStatus, getArchiveReason, - getBankAccountRoute, getIntegrationIcon, getIntegrationNameFromExportMessage as getIntegrationNameFromExportMessageUtils, getNextApproverAccountID, @@ -307,7 +306,6 @@ function MoneyReportHeader({ const optimisticNextStep = isSubmitterSameAsNextApprover && policy?.preventSelfApproval ? buildOptimisticNextStepForPreventSelfApprovalsEnabled() : nextStep; const shouldShowNextStep = isFromPaidPolicy && !isInvoiceReport && !shouldShowStatusBar; - const bankAccountRoute = getBankAccountRoute(chatReport); const {nonHeldAmount, fullAmount, hasValidNonHeldAmount} = getNonHeldAndFullAmount(moneyRequestReport, shouldShowPayButton); const isAnyTransactionOnHold = hasHeldExpensesReportUtils(moneyRequestReport?.reportID); const {isDelegateAccessRestricted, showDelegateNoAccessModal} = useContext(DelegateNoAccessContext); @@ -472,7 +470,6 @@ function MoneyReportHeader({ const {formattedAmount: totalAmount} = hasOnlyHeldExpenses ? getAmount(CONST.REPORT.REPORT_PREVIEW_ACTIONS.REVIEW) : getAmount(CONST.REPORT.PRIMARY_ACTIONS.PAY); const paymentButtonOptions = usePaymentOptions({ - addBankAccountRoute: bankAccountRoute, currency: moneyRequestReport?.currency, iouReport: moneyRequestReport, chatReportID: chatReport?.reportID, @@ -552,7 +549,7 @@ function MoneyReportHeader({ iouReport={moneyRequestReport} onPress={confirmPayment} enablePaymentsRoute={ROUTES.ENABLE_PAYMENTS} - addBankAccountRoute={bankAccountRoute} + chatReport={chatReport} shouldHidePaymentOptions={!shouldShowPayButton} shouldShowApproveButton={shouldShowApproveButton} shouldDisableApproveButton={shouldDisableApproveButton} @@ -910,7 +907,7 @@ function MoneyReportHeader({ confirmPayment(payment)} enablePaymentsRoute={ROUTES.ENABLE_PAYMENTS} - addBankAccountRoute={bankAccountRoute} + chatReport={chatReport} isDisabled={isOffline} source={CONST.KYC_WALL_SOURCE.REPORT} chatReportID={chatReport?.reportID} diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index a2a34e5e88e4..08a1e94b34bb 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -124,8 +124,8 @@ type MoneyRequestConfirmationListProps = { /** Number of expenses to be created */ expensesNumber?: number; - /** Depending on expense report or personal IOU report, respective bank account route */ - bankAccountRoute?: Route; + /** Chat report for calculating bank account routes */ + chatReport?: OnyxEntry; /** The policyID of the request */ policyID?: string; @@ -205,7 +205,7 @@ function MoneyRequestConfirmationList({ selectedParticipants: selectedParticipantsProp, payeePersonalDetails: payeePersonalDetailsProp, isReadOnly = false, - bankAccountRoute = '', + chatReport, policyID, reportID = '', receiptPath = '', @@ -985,7 +985,7 @@ function MoneyRequestConfirmationList({ pressOnEnter onPress={confirm} enablePaymentsRoute={ROUTES.IOU_SEND_ENABLE_PAYMENTS} - addBankAccountRoute={bankAccountRoute} + chatReport={chatReport} shouldShowPersonalBankAccountOption currency={iouCurrencyCode} policyID={policyID} @@ -1045,7 +1045,7 @@ function MoneyRequestConfirmationList({ isReadOnly, iouType, confirm, - bankAccountRoute, + chatReport, iouCurrencyCode, policyID, isConfirmed, @@ -1152,7 +1152,7 @@ export default memo( deepEqual(prevProps.selectedParticipants, nextProps.selectedParticipants) && deepEqual(prevProps.payeePersonalDetails, nextProps.payeePersonalDetails) && prevProps.isReadOnly === nextProps.isReadOnly && - prevProps.bankAccountRoute === nextProps.bankAccountRoute && + prevProps.chatReport === nextProps.chatReport && prevProps.policyID === nextProps.policyID && prevProps.reportID === nextProps.reportID && prevProps.receiptPath === nextProps.receiptPath && diff --git a/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx b/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx index 1313ff1a2b62..4ed217aecc52 100644 --- a/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx +++ b/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx @@ -278,8 +278,6 @@ function MoneyRequestReportPreviewContent({ managerID, ]); - const bankAccountRoute = getBankAccountRoute(chatReport); - /* Show subtitle if at least one of the expenses is not being smart scanned, and either: - There is more than one expense – in this case, the "X expenses, Y scanning" subtitle is shown; @@ -522,7 +520,7 @@ function MoneyRequestReportPreviewContent({ onPaymentOptionsHide={onPaymentOptionsHide} confirmApproval={confirmApproval} enablePaymentsRoute={ROUTES.ENABLE_PAYMENTS} - addBankAccountRoute={bankAccountRoute} + chatReport={chatReport} shouldHidePaymentOptions={!shouldShowPayButton} kycWallAnchorAlignment={{ horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.LEFT, diff --git a/src/components/SettlementButton/index.tsx b/src/components/SettlementButton/index.tsx index 871cf29b7b90..60031985ee46 100644 --- a/src/components/SettlementButton/index.tsx +++ b/src/components/SettlementButton/index.tsx @@ -21,7 +21,6 @@ import type SettlementButtonProps from './types'; function SettlementButton({ addDebitCardRoute = ROUTES.IOU_SEND_ADD_DEBIT_CARD, - addBankAccountRoute = '', kycWallAnchorAlignment = { horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.LEFT, // button is at left, so horizontal anchor is at LEFT vertical: CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.TOP, // we assume that popover menu opens below the button, anchor is at TOP @@ -69,7 +68,6 @@ function SettlementButton({ const {isAccountLocked, showLockedAccountModal} = useContext(LockedAccountContext); const paymentButtonOptions = usePaymentOptions({ - addBankAccountRoute, currency, iouReport, chatReportID, @@ -100,7 +98,7 @@ function SettlementButton({ onPress(paymentType)} enablePaymentsRoute={enablePaymentsRoute} - addBankAccountRoute={addBankAccountRoute} + chatReport={chatReport} addDebitCardRoute={addDebitCardRoute} isDisabled={isOffline} source={CONST.KYC_WALL_SOURCE.REPORT} diff --git a/src/components/SettlementButton/types.ts b/src/components/SettlementButton/types.ts index 9fe5758ea048..305d0e1d2a6f 100644 --- a/src/components/SettlementButton/types.ts +++ b/src/components/SettlementButton/types.ts @@ -62,8 +62,8 @@ type SettlementButtonProps = { /** The size of button size */ buttonSize?: ButtonSizeValue; - /** Route for the Add Bank Account screen for a given navigation stack */ - addBankAccountRoute?: Route; + /** Chat report for calculating bank account routes */ + chatReport?: OnyxEntry; /** Route for the Add Debit Card screen for a given navigation stack */ addDebitCardRoute?: Route; diff --git a/src/hooks/usePaymentOptions.ts b/src/hooks/usePaymentOptions.ts index 40dc90c922d9..7da37ca790c0 100644 --- a/src/hooks/usePaymentOptions.ts +++ b/src/hooks/usePaymentOptions.ts @@ -7,6 +7,7 @@ import {formatPaymentMethods} from '@libs/PaymentUtils'; import getPolicyEmployeeAccountIDs from '@libs/PolicyEmployeeListUtils'; import { doesReportBelongToWorkspace, + getBankAccountRoute, isExpenseReport as isExpenseReportUtil, isIndividualInvoiceRoom as isIndividualInvoiceRoomUtil, isInvoiceReport as isInvoiceReportUtil, @@ -26,7 +27,6 @@ type CurrencyType = TupleToUnion; type UsePaymentOptionsProps = Pick< SettlementButtonProps, - | 'addBankAccountRoute' | 'currency' | 'iouReport' | 'chatReportID' @@ -45,7 +45,6 @@ type UsePaymentOptionsProps = Pick< * It dynamically generates payment or approval options to ensure the user interface reflects the correct actions possible for the user's current situation. */ function usePaymentOptions({ - addBankAccountRoute = '', currency = CONST.CURRENCY.USD, iouReport, chatReportID = '', @@ -174,7 +173,10 @@ function usePaymentOptions({ { text: translate('workspace.invoices.paymentMethods.addBankAccount'), icon: Expensicons.Bank, - onSelected: () => Navigation.navigate(addBankAccountRoute), + onSelected: () => { + const bankAccountRoute = getBankAccountRoute(chatReport); + Navigation.navigate(bankAccountRoute); + }, }, ], }); @@ -190,7 +192,10 @@ function usePaymentOptions({ { text: translate('workspace.invoices.paymentMethods.addBankAccount'), icon: Expensicons.Bank, - onSelected: () => Navigation.navigate(addBankAccountRoute), + onSelected: () => { + const bankAccountRoute = getBankAccountRoute(chatReport); + Navigation.navigate(bankAccountRoute); + }, }, { text: translate('iou.payElsewhere', {formattedAmount: ''}), diff --git a/src/pages/home/report/PureReportActionItem.tsx b/src/pages/home/report/PureReportActionItem.tsx index ce0fda7ca92c..2f6819c9ba2b 100644 --- a/src/pages/home/report/PureReportActionItem.tsx +++ b/src/pages/home/report/PureReportActionItem.tsx @@ -1011,7 +1011,7 @@ function PureReportActionItem({ Navigation.navigate(ROUTES.ENABLE_PAYMENTS)} enablePaymentsRoute={ROUTES.ENABLE_PAYMENTS} - addBankAccountRoute={ROUTES.BANK_ACCOUNT_PERSONAL} + chatReport={report} addDebitCardRoute={ROUTES.SETTINGS_ADD_DEBIT_CARD} chatReportID={targetReport?.reportID} iouReport={iouReport} diff --git a/src/pages/iou/MoneyRequestAmountForm.tsx b/src/pages/iou/MoneyRequestAmountForm.tsx index 4caa4ad7e707..1853b0fdbaf9 100644 --- a/src/pages/iou/MoneyRequestAmountForm.tsx +++ b/src/pages/iou/MoneyRequestAmountForm.tsx @@ -24,7 +24,7 @@ import type {BaseTextInputRef} from '@src/components/TextInput/BaseTextInput/typ import CONST from '@src/CONST'; import type {Route} from '@src/ROUTES'; import ROUTES from '@src/ROUTES'; -import type {SelectedTabRequest} from '@src/types/onyx'; +import type {Report, SelectedTabRequest} from '@src/types/onyx'; import type {PaymentMethodType} from '@src/types/onyx/OriginalMessage'; type CurrentMoney = {amount: string; currency: string; paymentMethod?: PaymentMethodType}; @@ -51,8 +51,8 @@ type MoneyRequestAmountFormProps = { /** The policyID of the request */ policyID?: string; - /** Depending on expense report or personal IOU report, respective bank account route */ - bankAccountRoute?: Route; + /** Chat report for calculating bank account routes */ + chatReport?: Report; /** Whether the currency symbol is pressable */ isCurrencyPressable?: boolean; @@ -88,7 +88,7 @@ function MoneyRequestAmountForm( skipConfirmation = false, iouType = CONST.IOU.TYPE.SUBMIT, policyID = '', - bankAccountRoute = '', + chatReport, onCurrencyButtonPress, onSubmitButtonPress, selectedTab = CONST.TAB_REQUEST.MANUAL, @@ -309,7 +309,7 @@ function MoneyRequestAmountForm( pressOnEnter onPress={submitAndNavigateToNextPage} enablePaymentsRoute={ROUTES.IOU_SEND_ENABLE_PAYMENTS} - addBankAccountRoute={bankAccountRoute} + chatReport={chatReport} addDebitCardRoute={ROUTES.IOU_SEND_ADD_DEBIT_CARD} currency={currency ?? CONST.CURRENCY.USD} policyID={policyID} diff --git a/src/pages/iou/request/step/IOURequestStepAmount.tsx b/src/pages/iou/request/step/IOURequestStepAmount.tsx index f07a9912235b..ef8ee5b773b7 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.tsx +++ b/src/pages/iou/request/step/IOURequestStepAmount.tsx @@ -318,7 +318,7 @@ function IOURequestStepAmount({ skipConfirmation={shouldSkipConfirmation ?? false} iouType={iouType} policyID={policy?.id} - bankAccountRoute={getBankAccountRoute(report)} + chatReport={report} ref={(e) => { textInput.current = e; }} diff --git a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx index af7ce0359b8b..ccc42db9ea53 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx @@ -1081,7 +1081,7 @@ function IOURequestStepConfirmation({ shouldDisplayReceipt={!isMovingTransactionFromTrackExpense && !isDistanceRequest && !isPerDiemRequest} isPolicyExpenseChat={isPolicyExpenseChat} policyID={getIOURequestPolicyID(transaction, report)} - bankAccountRoute={getBankAccountRoute(report)} + chatReport={report} iouMerchant={transaction?.merchant} iouCreated={transaction?.created} isDistanceRequest={isDistanceRequest} diff --git a/src/pages/settings/Wallet/WalletPage/WalletPage.tsx b/src/pages/settings/Wallet/WalletPage/WalletPage.tsx index ce3e14c06ff4..4f5ca52a70f9 100644 --- a/src/pages/settings/Wallet/WalletPage/WalletPage.tsx +++ b/src/pages/settings/Wallet/WalletPage/WalletPage.tsx @@ -516,7 +516,7 @@ function WalletPage({shouldListenForResize = false}: WalletPageProps) { setPersonalBankAccountContinueKYCOnSuccess(ROUTES.SETTINGS_WALLET); }} enablePaymentsRoute={ROUTES.SETTINGS_ENABLE_PAYMENTS} - addBankAccountRoute={ROUTES.SETTINGS_ADD_BANK_ACCOUNT.route} + chatReport={undefined} addDebitCardRoute={ROUTES.SETTINGS_ADD_DEBIT_CARD} source={hasActivatedWallet ? CONST.KYC_WALL_SOURCE.TRANSFER_BALANCE : CONST.KYC_WALL_SOURCE.ENABLE_WALLET} shouldIncludeDebitCard={hasActivatedWallet} From 58a93887297a3987c1db95467c2e62e47325c414 Mon Sep 17 00:00:00 2001 From: "marta.sudol" Date: Thu, 10 Jul 2025 14:39:06 +0200 Subject: [PATCH 02/12] perf: getBankAccountRoute usage optimization --- src/components/MoneyRequestConfirmationList.tsx | 1 - .../MoneyRequestReportPreviewContent.tsx | 1 - src/pages/iou/MoneyRequestAmountForm.tsx | 1 - src/pages/iou/request/step/IOURequestStepAmount.tsx | 2 +- src/pages/iou/request/step/IOURequestStepConfirmation.tsx | 2 +- src/pages/settings/Wallet/WalletPage/WalletPage.tsx | 1 - 6 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index 08a1e94b34bb..3ec117977326 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -56,7 +56,6 @@ import CONST from '@src/CONST'; import type {TranslationPaths} from '@src/languages/types'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; -import type {Route} from '@src/ROUTES'; import type * as OnyxTypes from '@src/types/onyx'; import type {Attendee, Participant} from '@src/types/onyx/IOU'; import type {PaymentMethodType} from '@src/types/onyx/OriginalMessage'; diff --git a/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx b/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx index 4ed217aecc52..4b8ea3b9b368 100644 --- a/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx +++ b/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx @@ -38,7 +38,6 @@ import {getConnectedIntegration} from '@libs/PolicyUtils'; import {getReportPreviewAction} from '@libs/ReportPreviewActionUtils'; import { areAllRequestsBeingSmartScanned as areAllRequestsBeingSmartScannedReportUtils, - getBankAccountRoute, getDisplayNameForParticipant, getInvoicePayerName, getMoneyReportPreviewName, diff --git a/src/pages/iou/MoneyRequestAmountForm.tsx b/src/pages/iou/MoneyRequestAmountForm.tsx index 1853b0fdbaf9..1735b62469aa 100644 --- a/src/pages/iou/MoneyRequestAmountForm.tsx +++ b/src/pages/iou/MoneyRequestAmountForm.tsx @@ -22,7 +22,6 @@ import Navigation from '@libs/Navigation/Navigation'; import variables from '@styles/variables'; import type {BaseTextInputRef} from '@src/components/TextInput/BaseTextInput/types'; import CONST from '@src/CONST'; -import type {Route} from '@src/ROUTES'; import ROUTES from '@src/ROUTES'; import type {Report, SelectedTabRequest} from '@src/types/onyx'; import type {PaymentMethodType} from '@src/types/onyx/OriginalMessage'; diff --git a/src/pages/iou/request/step/IOURequestStepAmount.tsx b/src/pages/iou/request/step/IOURequestStepAmount.tsx index ef8ee5b773b7..42e5957d4a04 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.tsx +++ b/src/pages/iou/request/step/IOURequestStepAmount.tsx @@ -12,7 +12,7 @@ import {navigateToParticipantPage} from '@libs/IOUUtils'; import Navigation from '@libs/Navigation/Navigation'; import {getParticipantsOption, getReportOption} from '@libs/OptionsListUtils'; import {isPaidGroupPolicy} from '@libs/PolicyUtils'; -import {getBankAccountRoute, getPolicyExpenseChat, getTransactionDetails, isArchivedReport, isPolicyExpenseChat} from '@libs/ReportUtils'; +import {getPolicyExpenseChat, getTransactionDetails, isArchivedReport, isPolicyExpenseChat} from '@libs/ReportUtils'; import {shouldRestrictUserBillableActions} from '@libs/SubscriptionUtils'; import {calculateTaxAmount, getAmount, getCurrency, getDefaultTaxCode, getRequestType, getTaxValue} from '@libs/TransactionUtils'; import MoneyRequestAmountForm from '@pages/iou/MoneyRequestAmountForm'; diff --git a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx index ccc42db9ea53..d20cde57de77 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx @@ -33,7 +33,7 @@ import Navigation from '@libs/Navigation/Navigation'; import {rand64} from '@libs/NumberUtils'; import {getParticipantsOption, getReportOption} from '@libs/OptionsListUtils'; import Performance from '@libs/Performance'; -import {generateReportID, getBankAccountRoute, getReportOrDraftReport, isProcessingReport, isReportOutstanding, isSelectedManagerMcTest} from '@libs/ReportUtils'; +import {generateReportID, getReportOrDraftReport, isProcessingReport, isReportOutstanding, isSelectedManagerMcTest} from '@libs/ReportUtils'; import {getAttendees, getDefaultTaxCode, getRateID, getRequestType, getValidWaypoints, hasReceipt, isScanRequest} from '@libs/TransactionUtils'; import ReceiptDropUI from '@pages/iou/ReceiptDropUI'; import type {FileObject} from '@pages/media/AttachmentModalScreen/types'; diff --git a/src/pages/settings/Wallet/WalletPage/WalletPage.tsx b/src/pages/settings/Wallet/WalletPage/WalletPage.tsx index 4f5ca52a70f9..01ea36bfe208 100644 --- a/src/pages/settings/Wallet/WalletPage/WalletPage.tsx +++ b/src/pages/settings/Wallet/WalletPage/WalletPage.tsx @@ -516,7 +516,6 @@ function WalletPage({shouldListenForResize = false}: WalletPageProps) { setPersonalBankAccountContinueKYCOnSuccess(ROUTES.SETTINGS_WALLET); }} enablePaymentsRoute={ROUTES.SETTINGS_ENABLE_PAYMENTS} - chatReport={undefined} addDebitCardRoute={ROUTES.SETTINGS_ADD_DEBIT_CARD} source={hasActivatedWallet ? CONST.KYC_WALL_SOURCE.TRANSFER_BALANCE : CONST.KYC_WALL_SOURCE.ENABLE_WALLET} shouldIncludeDebitCard={hasActivatedWallet} From 8cc56f4fd5f3d96b4fbc36ea95a0a1d404910458 Mon Sep 17 00:00:00 2001 From: Tomasz Misiukiewicz Date: Tue, 15 Jul 2025 14:44:12 +0200 Subject: [PATCH 03/12] address code review comments --- Mobile-Expensify | 2 +- src/components/MoneyRequestConfirmationList.tsx | 9 ++------- src/pages/home/report/PureReportActionItem.tsx | 2 +- .../iou/request/step/IOURequestStepConfirmation.tsx | 1 - 4 files changed, 4 insertions(+), 10 deletions(-) diff --git a/Mobile-Expensify b/Mobile-Expensify index 7fef8b877641..58e0be6d1b7b 160000 --- a/Mobile-Expensify +++ b/Mobile-Expensify @@ -1 +1 @@ -Subproject commit 7fef8b87764101e3db92944cdc05d2ef45ba7ef5 +Subproject commit 58e0be6d1b7bc5e5b8d494e22c7bae517ed7a852 diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index d2345bc5adee..740032303639 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -124,9 +124,6 @@ type MoneyRequestConfirmationListProps = { /** Number of expenses to be created */ expensesNumber?: number; - /** Chat report for calculating bank account routes */ - chatReport?: OnyxEntry; - /** The policyID of the request */ policyID?: string; @@ -208,7 +205,6 @@ function MoneyRequestConfirmationList({ selectedParticipants: selectedParticipantsProp, payeePersonalDetails: payeePersonalDetailsProp, isReadOnly = false, - chatReport, policyID, reportID = '', receiptPath = '', @@ -989,7 +985,7 @@ function MoneyRequestConfirmationList({ pressOnEnter onPress={confirm} enablePaymentsRoute={ROUTES.IOU_SEND_ENABLE_PAYMENTS} - chatReport={chatReport} + chatReportID={reportID} shouldShowPersonalBankAccountOption currency={iouCurrencyCode} policyID={policyID} @@ -1059,7 +1055,6 @@ function MoneyRequestConfirmationList({ isReadOnly, iouType, confirm, - chatReport, iouCurrencyCode, policyID, isConfirmed, @@ -1075,6 +1070,7 @@ function MoneyRequestConfirmationList({ shouldShowProductTrainingTooltip, renderProductTrainingTooltip, isConfirming, + reportID, ]); const listFooterContent = ( @@ -1170,7 +1166,6 @@ export default memo( deepEqual(prevProps.selectedParticipants, nextProps.selectedParticipants) && deepEqual(prevProps.payeePersonalDetails, nextProps.payeePersonalDetails) && prevProps.isReadOnly === nextProps.isReadOnly && - prevProps.chatReport === nextProps.chatReport && prevProps.policyID === nextProps.policyID && prevProps.reportID === nextProps.reportID && prevProps.receiptPath === nextProps.receiptPath && diff --git a/src/pages/home/report/PureReportActionItem.tsx b/src/pages/home/report/PureReportActionItem.tsx index 5677d7b9d69f..7f206371c906 100644 --- a/src/pages/home/report/PureReportActionItem.tsx +++ b/src/pages/home/report/PureReportActionItem.tsx @@ -978,7 +978,7 @@ function PureReportActionItem({ Navigation.navigate(ROUTES.ENABLE_PAYMENTS)} enablePaymentsRoute={ROUTES.ENABLE_PAYMENTS} - chatReport={report} + chatReport={targetReport} addDebitCardRoute={ROUTES.SETTINGS_ADD_DEBIT_CARD} chatReportID={targetReport?.reportID} iouReport={iouReport} diff --git a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx index 2c0d9c2e6974..e9c6349de943 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx @@ -1105,7 +1105,6 @@ function IOURequestStepConfirmation({ shouldDisplayReceipt={!isMovingTransactionFromTrackExpense && !isDistanceRequest && !isPerDiemRequest} isPolicyExpenseChat={isPolicyExpenseChat} policyID={getIOURequestPolicyID(transaction, report)} - chatReport={report} iouMerchant={transaction?.merchant} iouCreated={transaction?.created} isDistanceRequest={isDistanceRequest} From 79faf46bc74de5a0de1316c49050cf7e4663df6b Mon Sep 17 00:00:00 2001 From: Tomasz Misiukiewicz Date: Tue, 15 Jul 2025 16:08:57 +0200 Subject: [PATCH 04/12] remove unnecessary chatReport calls --- src/components/MoneyReportHeader.tsx | 1 - .../MoneyRequestReportPreviewContent.tsx | 1 - src/components/SettlementButton/types.ts | 3 --- 3 files changed, 5 deletions(-) diff --git a/src/components/MoneyReportHeader.tsx b/src/components/MoneyReportHeader.tsx index 8f3c42024749..a347960a0e0b 100644 --- a/src/components/MoneyReportHeader.tsx +++ b/src/components/MoneyReportHeader.tsx @@ -554,7 +554,6 @@ function MoneyReportHeader({ iouReport={moneyRequestReport} onPress={confirmPayment} enablePaymentsRoute={ROUTES.ENABLE_PAYMENTS} - chatReport={chatReport} shouldHidePaymentOptions={!shouldShowPayButton} shouldShowApproveButton={shouldShowApproveButton} shouldDisableApproveButton={shouldDisableApproveButton} diff --git a/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx b/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx index 7522bfaa2d79..d140d87cc0ef 100644 --- a/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx +++ b/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx @@ -524,7 +524,6 @@ function MoneyRequestReportPreviewContent({ onPaymentOptionsHide={onPaymentOptionsHide} confirmApproval={confirmApproval} enablePaymentsRoute={ROUTES.ENABLE_PAYMENTS} - chatReport={chatReport} shouldHidePaymentOptions={!shouldShowPayButton} kycWallAnchorAlignment={{ horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.LEFT, diff --git a/src/components/SettlementButton/types.ts b/src/components/SettlementButton/types.ts index 305d0e1d2a6f..527c99004063 100644 --- a/src/components/SettlementButton/types.ts +++ b/src/components/SettlementButton/types.ts @@ -62,9 +62,6 @@ type SettlementButtonProps = { /** The size of button size */ buttonSize?: ButtonSizeValue; - /** Chat report for calculating bank account routes */ - chatReport?: OnyxEntry; - /** Route for the Add Debit Card screen for a given navigation stack */ addDebitCardRoute?: Route; From ab9c06b0360c658b3c47bded7a22aeb738aa78e4 Mon Sep 17 00:00:00 2001 From: Tomasz Misiukiewicz Date: Wed, 16 Jul 2025 09:57:47 +0200 Subject: [PATCH 05/12] remove unnecessary chatReport --- src/components/KYCWall/BaseKYCWall.tsx | 4 ++-- src/components/KYCWall/types.ts | 3 --- src/components/SettlementButton/index.tsx | 1 - src/pages/home/report/PureReportActionItem.tsx | 1 - 4 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/components/KYCWall/BaseKYCWall.tsx b/src/components/KYCWall/BaseKYCWall.tsx index 0fe653a6bb3d..5aa6fac1703d 100644 --- a/src/components/KYCWall/BaseKYCWall.tsx +++ b/src/components/KYCWall/BaseKYCWall.tsx @@ -30,7 +30,6 @@ const POPOVER_MENU_ANCHOR_POSITION_HORIZONTAL_OFFSET = 20; // before continuing to take whatever action they originally intended to take. It requires a button as a child and a native event so we can get the coordinates and use it // to render the AddPaymentMethodMenu in the correct location. function KYCWall({ - chatReport, addDebitCardRoute, anchorAlignment = { horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.LEFT, @@ -52,6 +51,7 @@ function KYCWall({ const [fundList] = useOnyx(ONYXKEYS.FUND_LIST, {canBeMissing: true}); const [bankAccountList = getEmptyObject()] = useOnyx(ONYXKEYS.BANK_ACCOUNT_LIST, {canBeMissing: true}); const [reimbursementAccount] = useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT, {canBeMissing: true}); + const [chatReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${chatReportID}`, {canBeMissing: true}); const anchorRef = useRef(null); const transferBalanceButtonRef = useRef(null); @@ -126,7 +126,7 @@ function KYCWall({ Navigation.navigate(bankAccountRoute); } }, - [chatReport, addDebitCardRoute, iouReport, onSelectPaymentMethod], + [addDebitCardRoute, chatReport, iouReport, onSelectPaymentMethod], ); /** diff --git a/src/components/KYCWall/types.ts b/src/components/KYCWall/types.ts index 024212306f62..a9523b0c7891 100644 --- a/src/components/KYCWall/types.ts +++ b/src/components/KYCWall/types.ts @@ -22,9 +22,6 @@ type AnchorPosition = { type PaymentMethod = ValueOf; type KYCWallProps = { - /** Chat report for calculating bank account routes */ - chatReport?: OnyxEntry; - /** Route for the Add Debit Card screen for a given navigation stack */ addDebitCardRoute?: Route; diff --git a/src/components/SettlementButton/index.tsx b/src/components/SettlementButton/index.tsx index 60031985ee46..e89c582ffc66 100644 --- a/src/components/SettlementButton/index.tsx +++ b/src/components/SettlementButton/index.tsx @@ -98,7 +98,6 @@ function SettlementButton({ onPress(paymentType)} enablePaymentsRoute={enablePaymentsRoute} - chatReport={chatReport} addDebitCardRoute={addDebitCardRoute} isDisabled={isOffline} source={CONST.KYC_WALL_SOURCE.REPORT} diff --git a/src/pages/home/report/PureReportActionItem.tsx b/src/pages/home/report/PureReportActionItem.tsx index 3165d6694b82..a0bab6b82d8b 100644 --- a/src/pages/home/report/PureReportActionItem.tsx +++ b/src/pages/home/report/PureReportActionItem.tsx @@ -978,7 +978,6 @@ function PureReportActionItem({ Navigation.navigate(ROUTES.ENABLE_PAYMENTS)} enablePaymentsRoute={ROUTES.ENABLE_PAYMENTS} - chatReport={targetReport} addDebitCardRoute={ROUTES.SETTINGS_ADD_DEBIT_CARD} chatReportID={targetReport?.reportID} iouReport={iouReport} From 1a8d7a6a4d018ee5b02c88d05e619c9ac3952b83 Mon Sep 17 00:00:00 2001 From: Tomasz Misiukiewicz Date: Wed, 16 Jul 2025 10:59:00 +0200 Subject: [PATCH 06/12] fix typecheck --- Mobile-Expensify | 2 +- src/components/MoneyReportHeader.tsx | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Mobile-Expensify b/Mobile-Expensify index 965cbaa0b47f..12bc8ceac0ef 160000 --- a/Mobile-Expensify +++ b/Mobile-Expensify @@ -1 +1 @@ -Subproject commit 965cbaa0b47faa740313ab2a7c5f0d7afea82478 +Subproject commit 12bc8ceac0efb3fb55a20f0f60b0f2433c79545c diff --git a/src/components/MoneyReportHeader.tsx b/src/components/MoneyReportHeader.tsx index 066fd9781295..0bca126c77a6 100644 --- a/src/components/MoneyReportHeader.tsx +++ b/src/components/MoneyReportHeader.tsx @@ -923,7 +923,6 @@ function MoneyReportHeader({ confirmPayment(payment)} enablePaymentsRoute={ROUTES.ENABLE_PAYMENTS} - chatReport={chatReport} isDisabled={isOffline} source={CONST.KYC_WALL_SOURCE.REPORT} chatReportID={chatReport?.reportID} From 57bfb325121c9355949c3610c93feb67239e9812 Mon Sep 17 00:00:00 2001 From: Tomasz Misiukiewicz Date: Wed, 16 Jul 2025 11:05:08 +0200 Subject: [PATCH 07/12] fix typecheck --- Mobile-Expensify | 2 +- src/pages/iou/MoneyRequestAmountForm.tsx | 7 +------ src/pages/iou/request/step/IOURequestStepAmount.tsx | 1 - 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/Mobile-Expensify b/Mobile-Expensify index 12bc8ceac0ef..965cbaa0b47f 160000 --- a/Mobile-Expensify +++ b/Mobile-Expensify @@ -1 +1 @@ -Subproject commit 12bc8ceac0efb3fb55a20f0f60b0f2433c79545c +Subproject commit 965cbaa0b47faa740313ab2a7c5f0d7afea82478 diff --git a/src/pages/iou/MoneyRequestAmountForm.tsx b/src/pages/iou/MoneyRequestAmountForm.tsx index 1735b62469aa..4405b2d9a597 100644 --- a/src/pages/iou/MoneyRequestAmountForm.tsx +++ b/src/pages/iou/MoneyRequestAmountForm.tsx @@ -23,7 +23,7 @@ import variables from '@styles/variables'; import type {BaseTextInputRef} from '@src/components/TextInput/BaseTextInput/types'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; -import type {Report, SelectedTabRequest} from '@src/types/onyx'; +import type {SelectedTabRequest} from '@src/types/onyx'; import type {PaymentMethodType} from '@src/types/onyx/OriginalMessage'; type CurrentMoney = {amount: string; currency: string; paymentMethod?: PaymentMethodType}; @@ -50,9 +50,6 @@ type MoneyRequestAmountFormProps = { /** The policyID of the request */ policyID?: string; - /** Chat report for calculating bank account routes */ - chatReport?: Report; - /** Whether the currency symbol is pressable */ isCurrencyPressable?: boolean; @@ -87,7 +84,6 @@ function MoneyRequestAmountForm( skipConfirmation = false, iouType = CONST.IOU.TYPE.SUBMIT, policyID = '', - chatReport, onCurrencyButtonPress, onSubmitButtonPress, selectedTab = CONST.TAB_REQUEST.MANUAL, @@ -308,7 +304,6 @@ function MoneyRequestAmountForm( pressOnEnter onPress={submitAndNavigateToNextPage} enablePaymentsRoute={ROUTES.IOU_SEND_ENABLE_PAYMENTS} - chatReport={chatReport} addDebitCardRoute={ROUTES.IOU_SEND_ADD_DEBIT_CARD} currency={currency ?? CONST.CURRENCY.USD} policyID={policyID} diff --git a/src/pages/iou/request/step/IOURequestStepAmount.tsx b/src/pages/iou/request/step/IOURequestStepAmount.tsx index 42e5957d4a04..9a8af60500a8 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.tsx +++ b/src/pages/iou/request/step/IOURequestStepAmount.tsx @@ -318,7 +318,6 @@ function IOURequestStepAmount({ skipConfirmation={shouldSkipConfirmation ?? false} iouType={iouType} policyID={policy?.id} - chatReport={report} ref={(e) => { textInput.current = e; }} From 7d264090f70e4f6689b5d6298918f14394c189d9 Mon Sep 17 00:00:00 2001 From: Tomasz Misiukiewicz Date: Wed, 16 Jul 2025 11:54:10 +0200 Subject: [PATCH 08/12] bring back optional addBankAccountRoute to KYCWall --- src/components/KYCWall/BaseKYCWall.tsx | 5 +++-- src/components/KYCWall/types.ts | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/KYCWall/BaseKYCWall.tsx b/src/components/KYCWall/BaseKYCWall.tsx index 5aa6fac1703d..cb1f76825fe8 100644 --- a/src/components/KYCWall/BaseKYCWall.tsx +++ b/src/components/KYCWall/BaseKYCWall.tsx @@ -30,6 +30,7 @@ const POPOVER_MENU_ANCHOR_POSITION_HORIZONTAL_OFFSET = 20; // before continuing to take whatever action they originally intended to take. It requires a button as a child and a native event so we can get the coordinates and use it // to render the AddPaymentMethodMenu in the correct location. function KYCWall({ + addBankAccountRoute, addDebitCardRoute, anchorAlignment = { horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.LEFT, @@ -122,11 +123,11 @@ function KYCWall({ return; } - const bankAccountRoute = getBankAccountRoute(chatReport); + const bankAccountRoute = addBankAccountRoute ?? getBankAccountRoute(chatReport); Navigation.navigate(bankAccountRoute); } }, - [addDebitCardRoute, chatReport, iouReport, onSelectPaymentMethod], + [addBankAccountRoute, addDebitCardRoute, chatReport, iouReport, onSelectPaymentMethod], ); /** diff --git a/src/components/KYCWall/types.ts b/src/components/KYCWall/types.ts index a9523b0c7891..06fd42d3103a 100644 --- a/src/components/KYCWall/types.ts +++ b/src/components/KYCWall/types.ts @@ -22,6 +22,9 @@ type AnchorPosition = { type PaymentMethod = ValueOf; type KYCWallProps = { + /** Route for the Add Bank Account screen for a given navigation stack */ + addBankAccountRoute?: Route; + /** Route for the Add Debit Card screen for a given navigation stack */ addDebitCardRoute?: Route; From a4acaf94386f736ce161208102674832431376e7 Mon Sep 17 00:00:00 2001 From: Tomasz Misiukiewicz Date: Wed, 16 Jul 2025 13:58:27 +0200 Subject: [PATCH 09/12] add addBankAccountRoute to KYCWall --- src/pages/home/report/PureReportActionItem.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/home/report/PureReportActionItem.tsx b/src/pages/home/report/PureReportActionItem.tsx index a0bab6b82d8b..cb4af099ff56 100644 --- a/src/pages/home/report/PureReportActionItem.tsx +++ b/src/pages/home/report/PureReportActionItem.tsx @@ -978,6 +978,7 @@ function PureReportActionItem({ Navigation.navigate(ROUTES.ENABLE_PAYMENTS)} enablePaymentsRoute={ROUTES.ENABLE_PAYMENTS} + addBankAccountRoute={ROUTES.BANK_ACCOUNT_PERSONAL} addDebitCardRoute={ROUTES.SETTINGS_ADD_DEBIT_CARD} chatReportID={targetReport?.reportID} iouReport={iouReport} From e568570ce530cfb8382e9999f2143a0d22904216 Mon Sep 17 00:00:00 2001 From: Tomasz Misiukiewicz Date: Wed, 16 Jul 2025 14:04:25 +0200 Subject: [PATCH 10/12] pass chatReportID down to SettlementButton --- src/pages/iou/MoneyRequestAmountForm.tsx | 5 +++++ src/pages/iou/request/step/IOURequestStepAmount.tsx | 1 + src/pages/iou/request/step/IOURequestStepTaxAmountPage.tsx | 1 + 3 files changed, 7 insertions(+) diff --git a/src/pages/iou/MoneyRequestAmountForm.tsx b/src/pages/iou/MoneyRequestAmountForm.tsx index 4405b2d9a597..69ce003284cc 100644 --- a/src/pages/iou/MoneyRequestAmountForm.tsx +++ b/src/pages/iou/MoneyRequestAmountForm.tsx @@ -64,6 +64,9 @@ type MoneyRequestAmountFormProps = { /** Whether the user input should be kept or not */ shouldKeepUserInput?: boolean; + + /** The chatReportID of the request */ + chatReportID?: string; }; const isAmountInvalid = (amount: string) => !amount.length || parseFloat(amount) < 0.01; @@ -88,6 +91,7 @@ function MoneyRequestAmountForm( onSubmitButtonPress, selectedTab = CONST.TAB_REQUEST.MANUAL, shouldKeepUserInput = false, + chatReportID, }: MoneyRequestAmountFormProps, forwardedRef: ForwardedRef, ) { @@ -319,6 +323,7 @@ function MoneyRequestAmountForm( }} shouldShowPersonalBankAccountOption enterKeyEventListenerPriority={1} + chatReportID={chatReportID} /> ) : (