From d4cb8d8b7bf9be1df112e7a0812431a08f88a860 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Sun, 5 Jul 2026 07:05:10 +0530 Subject: [PATCH 1/4] Thread delegateAccountID through IOU request/track/distance action layer Signed-off-by: krishna2323 --- src/components/AddExistingExpenseFooter.tsx | 3 ++ .../MoneyRequestHeaderSecondaryActions.tsx | 3 ++ src/hooks/useBulkDuplicateAction.ts | 3 ++ src/hooks/useBulkDuplicateReportAction.ts | 3 ++ src/hooks/useExpenseActions.ts | 4 ++ src/libs/actions/IOU/Duplicate.ts | 13 +++++++ src/libs/actions/IOU/MoneyRequest.ts | 4 ++ src/libs/actions/IOU/MoneyRequestBuilder.ts | 9 ++--- src/libs/actions/IOU/Split.ts | 3 +- .../actions/IOU/SplitTransactionUpdate.ts | 4 ++ src/libs/actions/IOU/TrackExpense.ts | 6 ++- .../IOU/types/CreateTrackExpenseParams.ts | 3 +- src/pages/Share/SubmitDetailsPage.tsx | 4 ++ .../iou/request/step/AmountSubmission.ts | 4 ++ ...andleMoneyRequestStepDistanceNavigation.ts | 4 ++ .../hooks/useDistanceNavigation.ts | 3 ++ .../hooks/useOdometerNavigation.ts | 4 ++ .../index.native.tsx | 2 + .../step/IOURequestStepDistanceManual.tsx | 2 + .../components/ScanSkipConfirmation.tsx | 3 ++ .../step/confirmation/useExpenseSubmission.ts | 5 +++ .../IOU/BuildOnyxDataForMoneyRequestTest.ts | 4 ++ .../IOU/GetMoneyRequestInformationTest.ts | 1 + tests/actions/IOU/MoneyRequestTest.ts | 38 +++++++++++++++++++ tests/actions/IOU/RequestMoneyTest.ts | 25 ++++++++++++ .../actions/IOUTest/DeleteMoneyRequestTest.ts | 5 +++ tests/actions/IOUTest/DuplicateTest.ts | 18 +++++++++ tests/actions/IOUTest/PayMoneyRequestTest.ts | 6 +++ tests/actions/IOUTest/ReportWorkflowTest.ts | 8 ++++ tests/actions/IOUTest/SplitTest.ts | 20 ++++++++++ tests/actions/IOUTest/TrackExpenseTest.ts | 32 ++++++++++++++++ tests/actions/TransactionTest.ts | 5 +++ tests/ui/UnreadIndicatorsTest.tsx | 1 + tests/unit/GoogleTagManagerTest.tsx | 1 + 34 files changed, 241 insertions(+), 12 deletions(-) diff --git a/src/components/AddExistingExpenseFooter.tsx b/src/components/AddExistingExpenseFooter.tsx index c48c6ea07a5a..b48e8da2ab2f 100644 --- a/src/components/AddExistingExpenseFooter.tsx +++ b/src/components/AddExistingExpenseFooter.tsx @@ -1,3 +1,4 @@ +import useDelegateAccountID from '@hooks/useDelegateAccountID'; import useLocalize from '@hooks/useLocalize'; import useOnyx from '@hooks/useOnyx'; import usePermissions from '@hooks/usePermissions'; @@ -49,6 +50,7 @@ function AddExistingExpenseFooter({selectedIds, report, reportToConfirm, reportN const isASAPSubmitBetaEnabled = isBetaEnabled(CONST.BETAS.ASAP_SUBMIT); const session = useSession(); const personalDetails = usePersonalDetails(); + const delegateAccountID = useDelegateAccountID(); const [transactionViolations] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS); const [allReports] = useOnyx(ONYXKEYS.COLLECTION.REPORT); const [policyRecentlyUsedCurrencies] = useOnyx(ONYXKEYS.RECENTLY_USED_CURRENCIES); @@ -82,6 +84,7 @@ function AddExistingExpenseFooter({selectedIds, report, reportToConfirm, reportN personalDetails, betas, policyTagList: report?.policyID ? policyTagList : chatReportPolicyTagList, + delegateAccountID, }); } else { changeTransactionsReport({ diff --git a/src/components/MoneyRequestHeaderSecondaryActions.tsx b/src/components/MoneyRequestHeaderSecondaryActions.tsx index 35b8d2d4b0d8..c0e786986d90 100644 --- a/src/components/MoneyRequestHeaderSecondaryActions.tsx +++ b/src/components/MoneyRequestHeaderSecondaryActions.tsx @@ -2,6 +2,7 @@ import useConfirmModal from '@hooks/useConfirmModal'; import {useCurrencyListActions} from '@hooks/useCurrencyList'; import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; import useDefaultExpensePolicy from '@hooks/useDefaultExpensePolicy'; +import useDelegateAccountID from '@hooks/useDelegateAccountID'; import useDeleteTransactions from '@hooks/useDeleteTransactions'; import useDuplicateTransactionsAndViolations from '@hooks/useDuplicateTransactionsAndViolations'; import useEnvironment from '@hooks/useEnvironment'; @@ -107,6 +108,7 @@ function MoneyRequestHeaderSecondaryActions({reportID, onBackButtonPress}: Money const theme = useTheme(); const {translate, localeCompare} = useLocalize(); const {login: currentUserLogin, accountID, localCurrencyCode} = useCurrentUserPersonalDetails(); + const delegateAccountID = useDelegateAccountID(); const personalDetails = usePersonalDetails(); const expensifyIcons = useMemoizedLazyExpensifyIcons([ @@ -256,6 +258,7 @@ function MoneyRequestHeaderSecondaryActions({reportID, onBackButtonPress}: Money targetPolicyTags, currentUser: {accountID, email: currentUserLogin ?? ''}, currentUserLocalCurrency: localCurrencyCode ?? CONST.CURRENCY.USD, + delegateAccountID, }); } }; diff --git a/src/hooks/useBulkDuplicateAction.ts b/src/hooks/useBulkDuplicateAction.ts index 518826035149..ebeb832768f2 100644 --- a/src/hooks/useBulkDuplicateAction.ts +++ b/src/hooks/useBulkDuplicateAction.ts @@ -14,6 +14,7 @@ import {validTransactionDraftsSelector} from '@selectors/TransactionDraft'; import useCurrentUserPersonalDetails from './useCurrentUserPersonalDetails'; import useDefaultExpensePolicy from './useDefaultExpensePolicy'; +import useDelegateAccountID from './useDelegateAccountID'; import useOnyx from './useOnyx'; import usePermissions from './usePermissions'; @@ -32,6 +33,7 @@ type UseBulkDuplicateActionParams = { */ function useBulkDuplicateAction({selectedTransactionsKeys, allTransactions, allReports, searchData, onAfterDuplicate}: UseBulkDuplicateActionParams) { const {accountID, login: currentUserLogin, localCurrencyCode} = useCurrentUserPersonalDetails(); + const delegateAccountID = useDelegateAccountID(); const {clearSelectedTransactions} = useSearchSelectionActions(); const defaultExpensePolicy = useDefaultExpensePolicy(); const {isBetaEnabled} = usePermissions(); @@ -81,6 +83,7 @@ function useBulkDuplicateAction({selectedTransactionsKeys, allTransactions, allR recentWaypoints, currentUser: {accountID, email: currentUserLogin ?? ''}, currentUserLocalCurrency: localCurrencyCode ?? CONST.CURRENCY.USD, + delegateAccountID, }); if (onAfterDuplicate) { diff --git a/src/hooks/useBulkDuplicateReportAction.ts b/src/hooks/useBulkDuplicateReportAction.ts index a401388727e2..5d5e5a6fc4e9 100644 --- a/src/hooks/useBulkDuplicateReportAction.ts +++ b/src/hooks/useBulkDuplicateReportAction.ts @@ -14,6 +14,7 @@ import {hasSeenTourSelector} from '@selectors/Onboarding'; import useCurrentUserPersonalDetails from './useCurrentUserPersonalDetails'; import useDefaultExpensePolicy from './useDefaultExpensePolicy'; +import useDelegateAccountID from './useDelegateAccountID'; import useLocalize from './useLocalize'; import useOnyx from './useOnyx'; import usePermissions from './usePermissions'; @@ -26,6 +27,7 @@ type UseBulkDuplicateReportActionParams = { function useBulkDuplicateReportAction({selectedReports, allReports, searchData}: UseBulkDuplicateReportActionParams) { const currentUserPersonalDetails = useCurrentUserPersonalDetails(); + const delegateAccountID = useDelegateAccountID(); const {clearSelectedTransactions} = useSearchSelectionActions(); const defaultExpensePolicy = useDefaultExpensePolicy(); const {isBetaEnabled} = usePermissions(); @@ -67,6 +69,7 @@ function useBulkDuplicateReportAction({selectedReports, allReports, searchData}: recentWaypoints, currentUserLogin: currentUserPersonalDetails.login ?? '', currentUserAccountID: currentUserPersonalDetails?.accountID, + delegateAccountID, }); clearSelectedTransactions(undefined, true); diff --git a/src/hooks/useExpenseActions.ts b/src/hooks/useExpenseActions.ts index 6d0fd315fe34..be744f0babbb 100644 --- a/src/hooks/useExpenseActions.ts +++ b/src/hooks/useExpenseActions.ts @@ -58,6 +58,7 @@ import useConfirmModal from './useConfirmModal'; import {useCurrencyListActions} from './useCurrencyList'; import useCurrentUserPersonalDetails from './useCurrentUserPersonalDetails'; import useDefaultExpensePolicy from './useDefaultExpensePolicy'; +import useDelegateAccountID from './useDelegateAccountID'; import useDeleteTransactions from './useDeleteTransactions'; import useDuplicateTransactionsAndViolations from './useDuplicateTransactionsAndViolations'; import useEnvironment from './useEnvironment'; @@ -99,6 +100,7 @@ function useExpenseActions({reportID, isReportInSearch = false, backTo, onDuplic const isASAPSubmitBetaEnabled = isBetaEnabled(CONST.BETAS.ASAP_SUBMIT); const {getCurrencyDecimals} = useCurrencyListActions(); const currentUserPersonalDetails = useCurrentUserPersonalDetails(); + const delegateAccountID = useDelegateAccountID(); const {login: currentUserLogin, accountID, email} = currentUserPersonalDetails; const {currentSearchHash} = useSearchQueryContext(); const {removeTransaction} = useSearchSelectionActions(); @@ -265,6 +267,7 @@ function useExpenseActions({reportID, isReportInSearch = false, backTo, onDuplic targetPolicyTags, currentUser: {accountID: currentUserPersonalDetails?.accountID, email: currentUserPersonalDetails?.email ?? ''}, currentUserLocalCurrency: currentUserPersonalDetails?.localCurrencyCode ?? CONST.CURRENCY.USD, + delegateAccountID, }); } }; @@ -423,6 +426,7 @@ function useExpenseActions({reportID, isReportInSearch = false, backTo, onDuplic recentWaypoints: recentWaypoints ?? [], currentUserAccountID: currentUserPersonalDetails?.accountID, currentUserLogin: currentUserPersonalDetails?.email ?? '', + delegateAccountID, }); }, }, diff --git a/src/libs/actions/IOU/Duplicate.ts b/src/libs/actions/IOU/Duplicate.ts index b6bd96417ec6..f40104d3865f 100644 --- a/src/libs/actions/IOU/Duplicate.ts +++ b/src/libs/actions/IOU/Duplicate.ts @@ -759,6 +759,7 @@ type DuplicateExpenseTransactionParams = { optimisticReportPreviewActionID?: string; currentUser: CurrentUser; currentUserLocalCurrency: string | undefined; + delegateAccountID: number | undefined; }; function duplicateExpenseTransaction({ @@ -785,6 +786,7 @@ function duplicateExpenseTransaction({ optimisticReportPreviewActionID: externalReportPreviewActionID, currentUser, currentUserLocalCurrency, + delegateAccountID, }: DuplicateExpenseTransactionParams) { if (!transaction) { return; @@ -832,6 +834,7 @@ function duplicateExpenseTransaction({ betas, personalDetails, shouldDeferAutoSubmit, + delegateAccountID, }; // If no workspace is provided the expense should be unreported @@ -871,6 +874,7 @@ function duplicateExpenseTransaction({ betas, isSelfTourViewed, currentUserLocalCurrency, + delegateAccountID, }; return trackExpense(trackExpenseParams); } @@ -917,6 +921,7 @@ type DuplicateReportParams = { currentUserLogin: string; currentUserAccountID: number; shouldPlaySound?: boolean; + delegateAccountID: number | undefined; }; function duplicateReport({ @@ -940,6 +945,7 @@ function duplicateReport({ currentUserAccountID, currentUserLogin, shouldPlaySound = true, + delegateAccountID, }: DuplicateReportParams) { if (!targetPolicy || !parentChatReport) { return; @@ -1030,6 +1036,7 @@ function duplicateReport({ betas, personalDetails, shouldDeferAutoSubmit: !isLastExpense, + delegateAccountID, }; const result = createExpenseByType({ @@ -1075,6 +1082,7 @@ type BulkDuplicateExpensesParams = { recentWaypoints: OnyxEntry; currentUser: CurrentUser; currentUserLocalCurrency: string | undefined; + delegateAccountID: number | undefined; }; function bulkDuplicateExpenses({ @@ -1096,6 +1104,7 @@ function bulkDuplicateExpenses({ recentWaypoints, currentUser, currentUserLocalCurrency, + delegateAccountID, }: BulkDuplicateExpensesParams) { const transactionsToDuplicate = transactionIDs.map((id) => allTransactions[`${ONYXKEYS.COLLECTION.TRANSACTION}${id}`]).filter((t): t is OnyxTypes.Transaction => !!t); @@ -1191,6 +1200,7 @@ function bulkDuplicateExpenses({ optimisticReportPreviewActionID: currentReportPreviewActionID, currentUser, currentUserLocalCurrency, + delegateAccountID, }); if (result?.iouReport) { @@ -1226,6 +1236,7 @@ type BulkDuplicateReportsParams = { recentWaypoints: OnyxEntry; currentUserLogin: string; currentUserAccountID: number; + delegateAccountID: number | undefined; }; function bulkDuplicateReports({ @@ -1249,6 +1260,7 @@ function bulkDuplicateReports({ recentWaypoints, currentUserLogin, currentUserAccountID, + delegateAccountID, }: BulkDuplicateReportsParams) { const allTransactionsMap = getAllTransactions(); const transactionsByReportID = new Map(); @@ -1323,6 +1335,7 @@ function bulkDuplicateReports({ shouldPlaySound: false, currentUserAccountID, currentUserLogin, + delegateAccountID, }); } diff --git a/src/libs/actions/IOU/MoneyRequest.ts b/src/libs/actions/IOU/MoneyRequest.ts index 909064792a82..f706aba03cb2 100644 --- a/src/libs/actions/IOU/MoneyRequest.ts +++ b/src/libs/actions/IOU/MoneyRequest.ts @@ -93,6 +93,7 @@ type CreateTransactionParams = { optimisticTransactionIDs: string[]; optimisticChatReportID: string | undefined; currentUserLocalCurrency: string | undefined; + delegateAccountID: number | undefined; }; function createTransaction({ @@ -121,6 +122,7 @@ function createTransaction({ optimisticTransactionIDs, optimisticChatReportID, currentUserLocalCurrency, + delegateAccountID, }: CreateTransactionParams) { const draftTransactionIDs = Object.keys(allTransactionDrafts ?? {}); @@ -168,6 +170,7 @@ function createTransaction({ optimisticChatReportID, optimisticTransactionID, currentUserLocalCurrency, + delegateAccountID, }); } else { const existingTransactionID = getExistingTransactionID(transaction?.linkedTrackedExpenseReportAction); @@ -210,6 +213,7 @@ function createTransaction({ personalDetails, optimisticChatReportID, optimisticTransactionID, + delegateAccountID, }); } } diff --git a/src/libs/actions/IOU/MoneyRequestBuilder.ts b/src/libs/actions/IOU/MoneyRequestBuilder.ts index ffe1aa61a683..2cd5a8b197d2 100644 --- a/src/libs/actions/IOU/MoneyRequestBuilder.ts +++ b/src/libs/actions/IOU/MoneyRequestBuilder.ts @@ -186,8 +186,7 @@ type RequestMoneyInformation = { betas: OnyxEntry; personalDetails: OnyxEntry; shouldDeferAutoSubmit?: boolean; - // TODO: delegateAccountID will be made required in PR 10 when all callers pass the value (https://github.com/Expensify/App/issues/66425) - delegateAccountID?: number | undefined; + delegateAccountID: number | undefined; }; type MoneyRequestInformationParams = { @@ -221,8 +220,7 @@ type MoneyRequestInformationParams = { quickAction: OnyxEntry; policyRecentlyUsedCurrencies: string[]; personalDetails: OnyxEntry; - // TODO: delegateAccountID will be made required in PR 10 when all callers pass the value (https://github.com/Expensify/App/issues/66425) - delegateAccountID?: number | undefined; + delegateAccountID: number | undefined; }; type MoneyRequestOptimisticParams = { @@ -270,8 +268,7 @@ type BuildOnyxDataForMoneyRequestParams = { transactionViolations?: OnyxCollection; hasViolations: boolean; quickAction: OnyxEntry; - // TODO: delegateAccountID will be made required in PR 10 when all callers pass the value (https://github.com/Expensify/App/issues/66425) - delegateAccountID?: number | undefined; + delegateAccountID: number | undefined; personalDetails?: OnyxEntry; /** Whether this is a selfDM split transaction */ isSelfDMSplit?: boolean; diff --git a/src/libs/actions/IOU/Split.ts b/src/libs/actions/IOU/Split.ts index 6114823272b8..fc797443c186 100644 --- a/src/libs/actions/IOU/Split.ts +++ b/src/libs/actions/IOU/Split.ts @@ -145,8 +145,7 @@ type CreateDistanceRequestInformation = { optimisticReportPreviewActionID?: string; shouldDeferAutoSubmit?: boolean; previousOdometerDraft?: OnyxEntry; - // TODO: delegateAccountID will be made required in PR 10 when all callers pass the value (https://github.com/Expensify/App/issues/66425) - delegateAccountID?: number | undefined; + delegateAccountID: number | undefined; }; type CreateSplitsTransactionParams = Omit & { diff --git a/src/libs/actions/IOU/SplitTransactionUpdate.ts b/src/libs/actions/IOU/SplitTransactionUpdate.ts index 7b6da20796d6..5bea7d64c1da 100644 --- a/src/libs/actions/IOU/SplitTransactionUpdate.ts +++ b/src/libs/actions/IOU/SplitTransactionUpdate.ts @@ -590,6 +590,8 @@ function updateSplitTransactions({ policyRecentlyUsedCurrencies, betas, personalDetails, + // TODO: delegateAccountID will be threaded in PR 11 (https://github.com/Expensify/App/issues/66425) + delegateAccountID: undefined, } as MoneyRequestInformationParams; if (isReverseSplitOperation) { @@ -702,6 +704,8 @@ function updateSplitTransactions({ policyRecentlyUsedCurrencies, betas, personalDetails, + // TODO: delegateAccountID will be threaded in PR 11 (https://github.com/Expensify/App/issues/66425) + delegateAccountID: undefined, }); let updateMoneyRequestParamsOnyxData: OnyxData = {}; diff --git a/src/libs/actions/IOU/TrackExpense.ts b/src/libs/actions/IOU/TrackExpense.ts index d43512085c00..77e94b5f56e9 100644 --- a/src/libs/actions/IOU/TrackExpense.ts +++ b/src/libs/actions/IOU/TrackExpense.ts @@ -197,8 +197,7 @@ type GetTrackExpenseInformationParams = { defaultWorkspaceName?: string; optimisticChatReportID?: string; currentUserLocalCurrency: string | undefined; - // TODO: delegateAccountID will be made required in PR 10 when all callers pass the value (https://github.com/Expensify/App/issues/66425) - delegateAccountID?: number | undefined; + delegateAccountID: number | undefined; }; type DeleteTrackExpenseParams = { @@ -1951,6 +1950,7 @@ function convertBulkTrackedExpensesToIOU({ personalDetails, betas, policyTagList, + delegateAccountID, }: { transactions: OnyxTypes.Transaction[]; iouReport: OnyxEntry; @@ -1964,6 +1964,7 @@ function convertBulkTrackedExpensesToIOU({ personalDetails: OnyxEntry; betas: OnyxEntry; policyTagList: OnyxEntry; + delegateAccountID: number | undefined; }) { const iouReportID = iouReport?.reportID; @@ -2084,6 +2085,7 @@ function convertBulkTrackedExpensesToIOU({ policyParams: { policyTagList, }, + delegateAccountID, }); const isDistanceRequest = isDistanceRequestTransactionUtils(transaction); diff --git a/src/libs/actions/IOU/types/CreateTrackExpenseParams.ts b/src/libs/actions/IOU/types/CreateTrackExpenseParams.ts index 500b70f15a60..5cd08bf18762 100644 --- a/src/libs/actions/IOU/types/CreateTrackExpenseParams.ts +++ b/src/libs/actions/IOU/types/CreateTrackExpenseParams.ts @@ -40,8 +40,7 @@ type CreateTrackExpenseParams = { defaultWorkspaceName?: string; currentUserLocalCurrency: string | undefined; previousOdometerDraft?: OnyxEntry; - // TODO: delegateAccountID will be made required in PR 10 when all callers pass the value (https://github.com/Expensify/App/issues/66425) - delegateAccountID?: number | undefined; + delegateAccountID: number | undefined; // TODO: Remove optional (?) once all callers are updated in follow-up PRs of https://github.com/Expensify/App/issues/66578 reportActionsList?: OnyxCollection; // Personal details list is optional here because we only use/pass it for SHARE case diff --git a/src/pages/Share/SubmitDetailsPage.tsx b/src/pages/Share/SubmitDetailsPage.tsx index 4b81d07923e2..3dd8e5141ebf 100644 --- a/src/pages/Share/SubmitDetailsPage.tsx +++ b/src/pages/Share/SubmitDetailsPage.tsx @@ -289,6 +289,8 @@ function SubmitDetailsPage({ isSelfTourViewed, optimisticTransactionID, currentUserLocalCurrency: currentUserPersonalDetails.localCurrencyCode ?? CONST.CURRENCY.USD, + // TODO: delegateAccountID will be threaded in PR 10b (https://github.com/Expensify/App/issues/66425) + delegateAccountID: undefined, }); } else { const existingTransactionDraft = existingTransactionID ? transactionDrafts?.[existingTransactionID] : undefined; @@ -333,6 +335,8 @@ function SubmitDetailsPage({ betas, personalDetails, optimisticTransactionID, + // TODO: delegateAccountID will be threaded in PR 10b (https://github.com/Expensify/App/issues/66425) + delegateAccountID: undefined, }); } cleanupAndNavigateAfterExpenseCreate({ diff --git a/src/pages/iou/request/step/AmountSubmission.ts b/src/pages/iou/request/step/AmountSubmission.ts index 128ecccd668b..a274965c987a 100644 --- a/src/pages/iou/request/step/AmountSubmission.ts +++ b/src/pages/iou/request/step/AmountSubmission.ts @@ -389,6 +389,8 @@ function submitAmount({ isSelfTourViewed, optimisticChatReportID, optimisticTransactionID, + // TODO: delegateAccountID will be threaded in PR 10b (https://github.com/Expensify/App/issues/66425) + delegateAccountID: undefined, }); } else { const existingTransactionDraft = existingTransactionID ? transactionDrafts?.[existingTransactionID] : undefined; @@ -423,6 +425,8 @@ function submitAmount({ personalDetails: allPersonalDetails, optimisticChatReportID, optimisticTransactionID, + // TODO: delegateAccountID will be threaded in PR 10b (https://github.com/Expensify/App/issues/66425) + delegateAccountID: undefined, }); } cleanupAfterSkipConfirmSubmit(overrides.shouldHandleNavigation, { diff --git a/src/pages/iou/request/step/IOURequestStepDistance/handleMoneyRequestStepDistanceNavigation.ts b/src/pages/iou/request/step/IOURequestStepDistance/handleMoneyRequestStepDistanceNavigation.ts index fae24d3f1969..34279dc2e009 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance/handleMoneyRequestStepDistanceNavigation.ts +++ b/src/pages/iou/request/step/IOURequestStepDistance/handleMoneyRequestStepDistanceNavigation.ts @@ -101,6 +101,7 @@ type MoneyRequestStepDistanceNavigationParams = { optimisticChatReportID: string | undefined; reportDraft: OnyxEntry | undefined; action: IOUAction; + delegateAccountID: number | undefined; }; /** Amount + merchant for a manual-distance submit; pending placeholders otherwise (waypoint/GPS distance is computed server-side). */ @@ -195,6 +196,7 @@ function handleMoneyRequestStepDistanceNavigation({ optimisticChatReportID, reportDraft, action, + delegateAccountID, }: MoneyRequestStepDistanceNavigationParams): void { const isManualDistance = manualDistance !== undefined; const isOdometerDistance = odometerDistance !== undefined; @@ -330,6 +332,7 @@ function handleMoneyRequestStepDistanceNavigation({ optimisticTransactionID, optimisticChatReportID, currentUserLocalCurrency, + delegateAccountID, }); cleanupAfterSkipConfirmSubmit(overrides.shouldHandleNavigation, { report, @@ -405,6 +408,7 @@ function handleMoneyRequestStepDistanceNavigation({ policyParams: { policyTagList, }, + delegateAccountID, }); cleanupAfterSkipConfirmSubmit(overrides.shouldHandleNavigation, { report, diff --git a/src/pages/iou/request/step/IOURequestStepDistance/hooks/useDistanceNavigation.ts b/src/pages/iou/request/step/IOURequestStepDistance/hooks/useDistanceNavigation.ts index d422e2334886..ffa0ee0cfdd8 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance/hooks/useDistanceNavigation.ts +++ b/src/pages/iou/request/step/IOURequestStepDistance/hooks/useDistanceNavigation.ts @@ -1,5 +1,6 @@ import type {LocaleContextProps} from '@components/LocaleContextProvider'; +import useDelegateAccountID from '@hooks/useDelegateAccountID'; import useOnyx from '@hooks/useOnyx'; import {rand64} from '@libs/NumberUtils'; @@ -144,6 +145,7 @@ function useDistanceNavigation({ const [transactionViolations] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS); const reportIDToCheck = isMoneyRequestReport(report) ? report?.chatReportID : report?.reportID; const [reportDraft] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_DRAFT}${reportIDToCheck}`); + const delegateAccountID = useDelegateAccountID(); return () => { const optimisticTransactionID = rand64(); const optimisticChatReportID = selfDMReport?.reportID ?? generateReportID(); @@ -189,6 +191,7 @@ function useDistanceNavigation({ optimisticTransactionID, optimisticChatReportID, reportDraft, + delegateAccountID, }); }; } diff --git a/src/pages/iou/request/step/IOURequestStepDistance/hooks/useOdometerNavigation.ts b/src/pages/iou/request/step/IOURequestStepDistance/hooks/useOdometerNavigation.ts index cde930a180c6..e6874aafe160 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance/hooks/useOdometerNavigation.ts +++ b/src/pages/iou/request/step/IOURequestStepDistance/hooks/useOdometerNavigation.ts @@ -1,5 +1,6 @@ import type {LocaleContextProps} from '@components/LocaleContextProvider'; +import useDelegateAccountID from '@hooks/useDelegateAccountID'; import useOnyx from '@hooks/useOnyx'; import {rand64} from '@libs/NumberUtils'; @@ -148,6 +149,8 @@ function useOdometerNavigation({ const reportIDToCheck = isMoneyRequestReport(report) ? report?.chatReportID : report?.reportID; const [reportDraft] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_DRAFT}${reportIDToCheck}`); + const delegateAccountID = useDelegateAccountID(); + return ({odometerStart, odometerEnd, odometerDistance, unit, previousOdometerDraft}: NavigateOptions) => { const optimisticTransactionID = rand64(); const optimisticChatReportID = selfDMReport?.reportID ?? generateReportID(); @@ -196,6 +199,7 @@ function useOdometerNavigation({ optimisticTransactionID, optimisticChatReportID, reportDraft, + delegateAccountID, }); }; } diff --git a/src/pages/iou/request/step/IOURequestStepDistanceGPS/index.native.tsx b/src/pages/iou/request/step/IOURequestStepDistanceGPS/index.native.tsx index 57f367d6e9c9..ea0bc47f3adb 100644 --- a/src/pages/iou/request/step/IOURequestStepDistanceGPS/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistanceGPS/index.native.tsx @@ -165,6 +165,8 @@ function IOURequestStepDistanceGPS({ optimisticTransactionID, optimisticChatReportID, reportDraft, + // TODO: delegateAccountID will be threaded in PR 10b (https://github.com/Expensify/App/issues/66425) + delegateAccountID: undefined, }); }; diff --git a/src/pages/iou/request/step/IOURequestStepDistanceManual.tsx b/src/pages/iou/request/step/IOURequestStepDistanceManual.tsx index c6f5c9012585..64ad5c11271f 100644 --- a/src/pages/iou/request/step/IOURequestStepDistanceManual.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistanceManual.tsx @@ -285,6 +285,8 @@ function IOURequestStepDistanceManual({ optimisticTransactionID, optimisticChatReportID, reportDraft, + // TODO: delegateAccountID will be threaded in PR 10b (https://github.com/Expensify/App/issues/66425) + delegateAccountID: undefined, }); }; diff --git a/src/pages/iou/request/step/IOURequestStepScan/components/ScanSkipConfirmation.tsx b/src/pages/iou/request/step/IOURequestStepScan/components/ScanSkipConfirmation.tsx index becc825f8ae9..a09c4d43df9f 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/components/ScanSkipConfirmation.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/components/ScanSkipConfirmation.tsx @@ -2,6 +2,7 @@ import {useFullScreenLoaderActions} from '@components/FullScreenLoaderContext'; import withCurrentUserPersonalDetails from '@components/withCurrentUserPersonalDetails'; import type {WithCurrentUserPersonalDetailsProps} from '@components/withCurrentUserPersonalDetails'; +import useDelegateAccountID from '@hooks/useDelegateAccountID'; import useFilesValidation from '@hooks/useFilesValidation'; import useOnyx from '@hooks/useOnyx'; import useOptimisticDraftTransactions from '@hooks/useOptimisticDraftTransactions'; @@ -76,6 +77,7 @@ function ScanSkipConfirmation({report, action, iouType, reportID, transactionID, const reportAttributesDerived = useReportAttributes(); const {isBetaEnabled} = usePermissions(); const isASAPSubmitBetaEnabled = isBetaEnabled(CONST.BETAS.ASAP_SUBMIT); + const delegateAccountID = useDelegateAccountID(); const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST); const [quickAction] = useOnyx(ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE); @@ -276,6 +278,7 @@ function ScanSkipConfirmation({report, action, iouType, reportID, transactionID, optimisticTransactionIDs, optimisticChatReportID, currentUserLocalCurrency: currentUserPersonalDetails.localCurrencyCode ?? CONST.CURRENCY.USD, + delegateAccountID, }; const scanDestinationReportID = iouType === CONST.IOU.TYPE.TRACK ? (report?.reportID ?? selfDMReport?.reportID) : report?.reportID; diff --git a/src/pages/iou/request/step/confirmation/useExpenseSubmission.ts b/src/pages/iou/request/step/confirmation/useExpenseSubmission.ts index 181266b3a21e..e2ce2ef1ef7e 100644 --- a/src/pages/iou/request/step/confirmation/useExpenseSubmission.ts +++ b/src/pages/iou/request/step/confirmation/useExpenseSubmission.ts @@ -1,4 +1,5 @@ import useActivePolicy from '@hooks/useActivePolicy'; +import useDelegateAccountID from '@hooks/useDelegateAccountID'; import useLastWorkspaceNumber from '@hooks/useLastWorkspaceNumber'; import useLocalize from '@hooks/useLocalize'; import useOnboardingTaskInformation from '@hooks/useOnboardingTaskInformation'; @@ -267,6 +268,7 @@ function useExpenseSubmission(params: UseExpenseSubmissionParams) { const [gpsDraftDetails] = useOnyx(ONYXKEYS.GPS_DRAFT_DETAILS); const [recentWaypoints] = useOnyx(ONYXKEYS.NVP_RECENT_WAYPOINTS); const [odometerDraft] = useOnyx(ONYXKEYS.ODOMETER_DRAFT); + const delegateAccountID = useDelegateAccountID(); const [delegateEmail] = useOnyx(ONYXKEYS.ACCOUNT, {selector: delegateEmailSelector}); // Onboarding task data const { @@ -485,6 +487,7 @@ function useExpenseSubmission(params: UseExpenseSubmissionParams) { isSelfTourViewed, betas, personalDetails, + delegateAccountID, }); existingIOUReport = iouReport; if (!iouReport) { @@ -697,6 +700,7 @@ function useExpenseSubmission(params: UseExpenseSubmissionParams) { reportActionsList: policyExpenseChatReportActions, personalDetailsList: personalDetails, currentUserLocalCurrency: currentUserPersonalDetails.localCurrencyCode ?? CONST.CURRENCY.USD, + delegateAccountID, }); } performPostBatchCleanup({ @@ -764,6 +768,7 @@ function useExpenseSubmission(params: UseExpenseSubmissionParams) { shouldHandleNavigation, shouldDeferForSearch, previousOdometerDraft: odometerDraft, + delegateAccountID, }); } diff --git a/tests/actions/IOU/BuildOnyxDataForMoneyRequestTest.ts b/tests/actions/IOU/BuildOnyxDataForMoneyRequestTest.ts index ced81546f57e..fc51ef1f20e1 100644 --- a/tests/actions/IOU/BuildOnyxDataForMoneyRequestTest.ts +++ b/tests/actions/IOU/BuildOnyxDataForMoneyRequestTest.ts @@ -188,6 +188,7 @@ describe('buildOnyxDataForMoneyRequest', () => { isSelfDMSplit: true, selfDMReportID: selfDMReport.reportID, optimisticParams: buildBaseOptimisticParams(IOU_REPORT_ID), + delegateAccountID: undefined, }; } @@ -328,6 +329,7 @@ describe('buildOnyxDataForMoneyRequest', () => { quickAction: undefined, isSelfDMSplit: false, optimisticParams: buildBaseOptimisticParams(IOU_REPORT_ID), + delegateAccountID: undefined, }; } @@ -367,6 +369,7 @@ describe('buildOnyxDataForMoneyRequest', () => { isSelfDMSplit: true, selfDMReportID: undefined, optimisticParams: buildBaseOptimisticParams(IOU_REPORT_ID), + delegateAccountID: undefined, }; } @@ -412,6 +415,7 @@ describe('buildOnyxDataForMoneyRequest', () => { } as Report, }, }, + delegateAccountID: undefined, }; } diff --git a/tests/actions/IOU/GetMoneyRequestInformationTest.ts b/tests/actions/IOU/GetMoneyRequestInformationTest.ts index 3d6b247e6278..431a95fb3f8e 100644 --- a/tests/actions/IOU/GetMoneyRequestInformationTest.ts +++ b/tests/actions/IOU/GetMoneyRequestInformationTest.ts @@ -68,6 +68,7 @@ const baseParams = { quickAction: undefined, policyRecentlyUsedCurrencies: [] as string[], personalDetails: {}, + delegateAccountID: undefined, } as const; describe('getMoneyRequestInformation', () => { diff --git a/tests/actions/IOU/MoneyRequestTest.ts b/tests/actions/IOU/MoneyRequestTest.ts index 78e607bf2783..9e5d34bd43f7 100644 --- a/tests/actions/IOU/MoneyRequestTest.ts +++ b/tests/actions/IOU/MoneyRequestTest.ts @@ -140,6 +140,7 @@ describe('MoneyRequest', () => { optimisticTransactionIDs: ['mock-txn-id'], optimisticChatReportID: undefined, currentUserLocalCurrency: undefined, + delegateAccountID: undefined, }; beforeEach(async () => { @@ -155,6 +156,7 @@ describe('MoneyRequest', () => { ...baseParams, iouType: CONST.IOU.TYPE.TRACK, allTransactionDrafts: {}, + delegateAccountID: undefined, }); expect(TrackExpense.trackExpense).toHaveBeenCalledTimes(1); @@ -196,6 +198,7 @@ describe('MoneyRequest', () => { ...baseParams, iouType: CONST.IOU.TYPE.SEND, allTransactionDrafts: {}, + delegateAccountID: undefined, }); expect(TrackExpense.requestMoney).toHaveBeenCalledTimes(1); @@ -244,6 +247,7 @@ describe('MoneyRequest', () => { iouType: CONST.IOU.TYPE.TRACK, files, allTransactionDrafts: {}, + delegateAccountID: undefined, }); expect(TrackExpense.trackExpense).toHaveBeenCalledTimes(files.length); @@ -258,6 +262,7 @@ describe('MoneyRequest', () => { ...baseParams, files, allTransactionDrafts: {}, + delegateAccountID: undefined, }); expect(TrackExpense.requestMoney).toHaveBeenCalledWith( @@ -277,6 +282,7 @@ describe('MoneyRequest', () => { ...baseParams, currentUserEmail: undefined, allTransactionDrafts: {}, + delegateAccountID: undefined, }); expect(TrackExpense.requestMoney).toHaveBeenCalledWith( @@ -309,6 +315,7 @@ describe('MoneyRequest', () => { allTransactionDrafts: { [draftTransaction.transactionID]: draftTransaction, }, + delegateAccountID: undefined, }); expect(TrackExpense.requestMoney).toHaveBeenCalledWith( @@ -323,6 +330,7 @@ describe('MoneyRequest', () => { createTransaction({ ...baseParams, allTransactionDrafts: undefined, + delegateAccountID: undefined, }); expect(TrackExpense.requestMoney).toHaveBeenCalledWith( @@ -338,6 +346,7 @@ describe('MoneyRequest', () => { iouType: CONST.IOU.TYPE.TRACK, billable: true, reimbursable: false, + delegateAccountID: undefined, }); expect(TrackExpense.trackExpense).toHaveBeenCalledWith( @@ -354,6 +363,7 @@ describe('MoneyRequest', () => { createTransaction({ ...baseParams, allTransactionDrafts: {}, + delegateAccountID: undefined, }); expect(TrackExpense.requestMoney).toHaveBeenCalledWith( @@ -387,6 +397,7 @@ describe('MoneyRequest', () => { [draft1.transactionID]: draft1, [draft2.transactionID]: draft2, }, + delegateAccountID: undefined, }); expect(TrackExpense.requestMoney).toHaveBeenCalledWith( @@ -402,6 +413,7 @@ describe('MoneyRequest', () => { ...baseParams, iouType: CONST.IOU.TYPE.TRACK, gpsPoint, + delegateAccountID: undefined, }); expect(TrackExpense.trackExpense).toHaveBeenCalledWith( @@ -437,6 +449,7 @@ describe('MoneyRequest', () => { iouType: CONST.IOU.TYPE.TRACK, transactions: [transactionWithoutTax], policyParams: {policy: policyWithTax}, + delegateAccountID: undefined, }); expect(TrackExpense.trackExpense).toHaveBeenCalledWith( @@ -473,6 +486,7 @@ describe('MoneyRequest', () => { iouType: CONST.IOU.TYPE.REQUEST, transactions: [transactionWithoutTax], policyParams: {policy: policyWithTax}, + delegateAccountID: undefined, }); expect(TrackExpense.requestMoney).toHaveBeenCalledWith( @@ -509,6 +523,7 @@ describe('MoneyRequest', () => { iouType: CONST.IOU.TYPE.TRACK, transactions: [transactionWithTax], policyParams: {policy: policyWithTax}, + delegateAccountID: undefined, }); expect(TrackExpense.trackExpense).toHaveBeenCalledWith( @@ -533,6 +548,7 @@ describe('MoneyRequest', () => { iouType: CONST.IOU.TYPE.REQUEST, transactions: [transactionWithoutTax], policyParams: undefined, + delegateAccountID: undefined, }); expect(TrackExpense.requestMoney).toHaveBeenCalledWith( @@ -551,6 +567,7 @@ describe('MoneyRequest', () => { iouType: CONST.IOU.TYPE.REQUEST, optimisticTransactionIDs: ['ui-id-1'], allTransactionDrafts: {}, + delegateAccountID: undefined, }); const requestMoneyArg = jest.mocked(TrackExpense.requestMoney).mock.calls.at(0)?.at(0); expect(requestMoneyArg?.optimisticTransactionID).toBe('ui-id-1'); @@ -564,6 +581,7 @@ describe('MoneyRequest', () => { participant: {accountID: 222, login: 'test@test.com'}, optimisticChatReportID: 'ui-resolved-chat', allTransactionDrafts: {}, + delegateAccountID: undefined, }); const requestMoneyArg = jest.mocked(TrackExpense.requestMoney).mock.calls.at(0)?.at(0); expect(requestMoneyArg?.optimisticChatReportID).toBe('ui-resolved-chat'); @@ -654,6 +672,7 @@ describe('MoneyRequest', () => { ...baseParams, backTo, draftTransactionIDs: [baseParams.transactionID], + delegateAccountID: undefined, }); expect(Navigation.goBack).toHaveBeenCalledWith(backTo); @@ -664,6 +683,7 @@ describe('MoneyRequest', () => { ...baseParams, backTo, draftTransactionIDs: undefined, + delegateAccountID: undefined, }); expect(Navigation.goBack).toHaveBeenCalledWith(backTo); @@ -682,6 +702,7 @@ describe('MoneyRequest', () => { shouldSkipConfirmation: true, iouType: CONST.IOU.TYPE.TRACK, draftTransactionIDs: [baseParams.transactionID], + delegateAccountID: undefined, }); expect(Split.resetSplitShares).toHaveBeenCalledWith(splitTransaction, undefined, undefined, 1); @@ -694,6 +715,7 @@ describe('MoneyRequest', () => { shouldSkipConfirmation: true, iouType: CONST.IOU.TYPE.TRACK, draftTransactionIDs: [baseParams.transactionID], + delegateAccountID: undefined, }); expect(Split.resetSplitShares).not.toHaveBeenCalled(); @@ -747,6 +769,7 @@ describe('MoneyRequest', () => { iouType: CONST.IOU.TYPE.TRACK, optimisticTransactionID: 'optimistic-should-be-ignored', draftTransactionIDs: [baseParams.transactionID], + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -768,6 +791,7 @@ describe('MoneyRequest', () => { iouType: CONST.IOU.TYPE.SUBMIT, optimisticTransactionID: 'optimistic-should-be-ignored', draftTransactionIDs: [baseParams.transactionID], + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -812,6 +836,7 @@ describe('MoneyRequest', () => { shouldSkipConfirmation: true, iouType: CONST.IOU.TYPE.TRACK, draftTransactionIDs: [baseParams.transactionID], + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -877,6 +902,7 @@ describe('MoneyRequest', () => { manualDistance: 20, iouType: CONST.IOU.TYPE.SUBMIT, draftTransactionIDs: [baseParams.transactionID], + delegateAccountID: undefined, }); expect(Split.createDistanceRequest).toHaveBeenCalledWith( @@ -916,6 +942,7 @@ describe('MoneyRequest', () => { manualDistance: undefined, iouType: CONST.IOU.TYPE.SUBMIT, draftTransactionIDs: [baseParams.transactionID], + delegateAccountID: undefined, }); expect(Split.createDistanceRequest).toHaveBeenCalledWith( @@ -954,6 +981,7 @@ describe('MoneyRequest', () => { shouldSkipConfirmation: false, iouType: CONST.IOU.TYPE.SUBMIT, draftTransactionIDs: [baseParams.transactionID], + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -990,6 +1018,7 @@ describe('MoneyRequest', () => { isAutoReporting: true, iouType: CONST.IOU.TYPE.CREATE, draftTransactionIDs: [baseParams.transactionID], + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -1031,6 +1060,7 @@ describe('MoneyRequest', () => { defaultExpensePolicy, iouType: CONST.IOU.TYPE.CREATE, draftTransactionIDs: [baseParams.transactionID], + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -1043,6 +1073,7 @@ describe('MoneyRequest', () => { ...baseParams, iouType: CONST.IOU.TYPE.CREATE, draftTransactionIDs: [baseParams.transactionID], + delegateAccountID: undefined, }); expect(Navigation.navigate).toHaveBeenCalledWith(ROUTES.MONEY_REQUEST_STEP_PARTICIPANTS.getRoute(CONST.IOU.TYPE.CREATE, baseParams.transactionID, baseParams.reportID)); @@ -1055,6 +1086,7 @@ describe('MoneyRequest', () => { defaultExpensePolicy: undefined, iouType: CONST.IOU.TYPE.CREATE, amountOwed: 8010, + delegateAccountID: undefined, }); expect(Navigation.navigate).toHaveBeenCalledWith(ROUTES.MONEY_REQUEST_STEP_PARTICIPANTS.getRoute(CONST.IOU.TYPE.CREATE, baseParams.transactionID, baseParams.reportID)); @@ -1069,6 +1101,7 @@ describe('MoneyRequest', () => { iouType: CONST.IOU.TYPE.CREATE, amountOwed: 100, ownerBillingGracePeriodEnd: pastDate, + delegateAccountID: undefined, }); expect(Navigation.navigate).toHaveBeenCalledWith(ROUTES.MONEY_REQUEST_STEP_PARTICIPANTS.getRoute(CONST.IOU.TYPE.CREATE, baseParams.transactionID, baseParams.reportID)); @@ -1080,6 +1113,7 @@ describe('MoneyRequest', () => { report: undefined, defaultExpensePolicy: fakePolicy, iouType: CONST.IOU.TYPE.CREATE, + delegateAccountID: undefined, }); const lastCallArgs = jest.mocked(shouldUseDefaultExpensePolicy).mock.calls.at(-1) ?? []; @@ -1095,6 +1129,7 @@ describe('MoneyRequest', () => { isArchivedExpenseReport: false, draftTransactionIDs: [baseParams.transactionID], conciergeReportID, + delegateAccountID: undefined, }); // When report exists and iouType is not CREATE, the function calls getMoneyRequestParticipantOptions @@ -1111,6 +1146,7 @@ describe('MoneyRequest', () => { isArchivedExpenseReport: false, draftTransactionIDs: [baseParams.transactionID], conciergeReportID: undefined, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -1129,6 +1165,7 @@ describe('MoneyRequest', () => { setDistanceRequestData: (participants) => { capturedParticipants = participants; }, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -1148,6 +1185,7 @@ describe('MoneyRequest', () => { setDistanceRequestData: (participants) => { capturedParticipants = participants; }, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); diff --git a/tests/actions/IOU/RequestMoneyTest.ts b/tests/actions/IOU/RequestMoneyTest.ts index 29c54cf15cf8..2fc508d46252 100644 --- a/tests/actions/IOU/RequestMoneyTest.ts +++ b/tests/actions/IOU/RequestMoneyTest.ts @@ -216,6 +216,7 @@ describe('actions/IOU', () => { quickAction: undefined, betas: [CONST.BETAS.ALL], personalDetails: {}, + delegateAccountID: undefined, }); return waitForBatchedUpdates() .then( @@ -481,6 +482,7 @@ describe('actions/IOU', () => { quickAction: undefined, betas: [CONST.BETAS.ALL], personalDetails: {}, + delegateAccountID: undefined, }); return waitForBatchedUpdates(); }) @@ -714,6 +716,7 @@ describe('actions/IOU', () => { quickAction: undefined, betas: [CONST.BETAS.ALL], personalDetails: {}, + delegateAccountID: undefined, }); } return waitForBatchedUpdates(); @@ -883,6 +886,7 @@ describe('actions/IOU', () => { quickAction: undefined, betas: [CONST.BETAS.ALL], personalDetails: {}, + delegateAccountID: undefined, }); return ( waitForBatchedUpdates() @@ -1289,6 +1293,7 @@ describe('actions/IOU', () => { draftTransactionIDs: [], isSelfTourViewed: false, currentUserLocalCurrency: undefined, + delegateAccountID: undefined, }); mockFetch?.resume?.(); @@ -1357,6 +1362,7 @@ describe('actions/IOU', () => { draftTransactionIDs: [], isSelfTourViewed: false, currentUserLocalCurrency: undefined, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -1405,6 +1411,7 @@ describe('actions/IOU', () => { quickAction: undefined, betas: [CONST.BETAS.ALL], personalDetails: {}, + delegateAccountID: undefined, }); expect(notifyNewAction).toHaveBeenCalledTimes(0); }); @@ -1437,6 +1444,7 @@ describe('actions/IOU', () => { quickAction: undefined, betas: [CONST.BETAS.ALL], personalDetails: {}, + delegateAccountID: undefined, }); expect(Navigation.setNavigationActionToMicrotaskQueue).toHaveBeenCalledTimes(1); }); @@ -1469,6 +1477,7 @@ describe('actions/IOU', () => { quickAction: undefined, betas: [CONST.BETAS.ALL], personalDetails: {}, + delegateAccountID: undefined, }); // Verify that the iouReport is created successfully when isSelfTourViewed is true expect(iouReport).toBeDefined(); @@ -1520,6 +1529,7 @@ describe('actions/IOU', () => { quickAction: undefined, betas: [CONST.BETAS.ALL], personalDetails: {}, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -1564,6 +1574,7 @@ describe('actions/IOU', () => { quickAction: undefined, betas: [CONST.BETAS.ALL], personalDetails: {}, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -1634,6 +1645,7 @@ describe('actions/IOU', () => { quickAction: undefined, betas: [CONST.BETAS.ALL], personalDetails: {}, + delegateAccountID: undefined, }); waitForBatchedUpdates(); @@ -1702,6 +1714,7 @@ describe('actions/IOU', () => { draftTransactionIDs: [], personalDetails: testPersonalDetails, betas: [CONST.BETAS.ALL], + delegateAccountID: undefined, }); expect(iouReport).toBeDefined(); @@ -1775,6 +1788,7 @@ describe('actions/IOU', () => { draftTransactionIDs: [], personalDetails: testPersonalDetails, betas: [CONST.BETAS.ALL], + delegateAccountID: undefined, }); expect(iouReport).toBeDefined(); @@ -1819,6 +1833,7 @@ describe('actions/IOU', () => { draftTransactionIDs: [], personalDetails: {}, betas: [CONST.BETAS.ALL], + delegateAccountID: undefined, }); // Should still create the expense even with empty personalDetails @@ -1881,6 +1896,7 @@ describe('actions/IOU', () => { draftTransactionIDs: [], isSelfTourViewed: false, currentUserLocalCurrency: undefined, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -1978,6 +1994,7 @@ describe('actions/IOU', () => { draftTransactionIDs: [], personalDetails: {}, betas: [CONST.BETAS.ALL], + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -2053,6 +2070,7 @@ describe('actions/IOU', () => { existingTransactionDraft: undefined, draftTransactionIDs: [], personalDetails: {}, + delegateAccountID: undefined, }); return waitForBatchedUpdates(); }) @@ -2140,6 +2158,7 @@ describe('actions/IOU', () => { existingTransactionDraft: undefined, draftTransactionIDs: [], personalDetails: {}, + delegateAccountID: undefined, }); return waitForBatchedUpdates(); }) @@ -2218,6 +2237,7 @@ describe('actions/IOU', () => { existingTransactionDraft: undefined, draftTransactionIDs: [], personalDetails: {}, + delegateAccountID: undefined, }); return waitForBatchedUpdates(); }) @@ -2291,6 +2311,7 @@ describe('actions/IOU', () => { existingTransactionDraft: undefined, draftTransactionIDs: [], personalDetails: {}, + delegateAccountID: undefined, }); return waitForBatchedUpdates(); }) @@ -2365,6 +2386,7 @@ describe('actions/IOU', () => { existingTransactionDraft: undefined, draftTransactionIDs: [], personalDetails: {}, + delegateAccountID: undefined, }); return waitForBatchedUpdates(); }) @@ -2457,6 +2479,7 @@ describe('actions/IOU', () => { quickAction: undefined, betas: [CONST.BETAS.ALL], personalDetails: {}, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -2530,6 +2553,7 @@ describe('actions/IOU', () => { existingTransactionDraft: undefined, draftTransactionIDs: [], personalDetails: {}, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -2604,6 +2628,7 @@ describe('actions/IOU', () => { draftTransactionIDs: [], isSelfTourViewed: false, currentUserLocalCurrency: undefined, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); diff --git a/tests/actions/IOUTest/DeleteMoneyRequestTest.ts b/tests/actions/IOUTest/DeleteMoneyRequestTest.ts index 86661ad5afef..3536b40baa47 100644 --- a/tests/actions/IOUTest/DeleteMoneyRequestTest.ts +++ b/tests/actions/IOUTest/DeleteMoneyRequestTest.ts @@ -191,6 +191,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { quickAction: undefined, betas: [CONST.BETAS.ALL], personalDetails: {}, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -446,6 +447,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { quickAction: undefined, betas: [CONST.BETAS.ALL], personalDetails: {}, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -1139,6 +1141,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { quickAction: undefined, betas: [CONST.BETAS.ALL], personalDetails: {}, + delegateAccountID: undefined, }); } @@ -1220,6 +1223,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { quickAction: undefined, betas: [CONST.BETAS.ALL], personalDetails: {}, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -1391,6 +1395,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { existingTransactionDraft: undefined, betas: [CONST.BETAS.ALL], personalDetails: {}, + delegateAccountID: undefined, }); } diff --git a/tests/actions/IOUTest/DuplicateTest.ts b/tests/actions/IOUTest/DuplicateTest.ts index bd2a277a0b97..4d4fdd35c386 100644 --- a/tests/actions/IOUTest/DuplicateTest.ts +++ b/tests/actions/IOUTest/DuplicateTest.ts @@ -1340,6 +1340,7 @@ describe('actions/Duplicate', () => { targetPolicyTags, currentUser: {accountID: RORY_ACCOUNT_ID, email: RORY_EMAIL}, currentUserLocalCurrency: undefined, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -1404,6 +1405,7 @@ describe('actions/Duplicate', () => { targetPolicyTags, currentUser: {accountID: RORY_ACCOUNT_ID, email: RORY_EMAIL}, currentUserLocalCurrency: undefined, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -1460,6 +1462,7 @@ describe('actions/Duplicate', () => { targetPolicyTags, currentUser: {accountID: RORY_ACCOUNT_ID, email: RORY_EMAIL}, currentUserLocalCurrency: undefined, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -1509,6 +1512,7 @@ describe('actions/Duplicate', () => { targetPolicyTags, currentUser: {accountID: RORY_ACCOUNT_ID, email: RORY_EMAIL}, currentUserLocalCurrency: undefined, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -1558,6 +1562,7 @@ describe('actions/Duplicate', () => { targetPolicyTags, currentUser: {accountID: RORY_ACCOUNT_ID, email: RORY_EMAIL}, currentUserLocalCurrency: undefined, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -1610,6 +1615,7 @@ describe('actions/Duplicate', () => { targetPolicyTags, currentUser: {accountID: RORY_ACCOUNT_ID, email: RORY_EMAIL}, currentUserLocalCurrency: undefined, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -1672,6 +1678,7 @@ describe('actions/Duplicate', () => { targetPolicyTags, currentUser: {accountID: RORY_ACCOUNT_ID, email: RORY_EMAIL}, currentUserLocalCurrency: undefined, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -1719,6 +1726,7 @@ describe('actions/Duplicate', () => { targetPolicyTags, currentUser: {accountID: RORY_ACCOUNT_ID, email: RORY_EMAIL}, currentUserLocalCurrency: undefined, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -1759,6 +1767,7 @@ describe('actions/Duplicate', () => { targetPolicyTags, currentUser: {accountID: RORY_ACCOUNT_ID, email: RORY_EMAIL}, currentUserLocalCurrency: undefined, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -1802,6 +1811,7 @@ describe('actions/Duplicate', () => { targetPolicyTags, currentUser: {accountID: RORY_ACCOUNT_ID, email: RORY_EMAIL}, currentUserLocalCurrency: undefined, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -1851,6 +1861,7 @@ describe('actions/Duplicate', () => { targetPolicyTags, currentUser: {accountID: RORY_ACCOUNT_ID, email: RORY_EMAIL}, currentUserLocalCurrency: undefined, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -1916,6 +1927,7 @@ describe('actions/Duplicate', () => { targetPolicyTags, currentUser: {accountID: RORY_ACCOUNT_ID, email: RORY_EMAIL}, currentUserLocalCurrency: undefined, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -1981,6 +1993,7 @@ describe('actions/Duplicate', () => { targetPolicyTags, currentUser: {accountID: RORY_ACCOUNT_ID, email: RORY_EMAIL}, currentUserLocalCurrency: undefined, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -2030,6 +2043,7 @@ describe('actions/Duplicate', () => { targetPolicyTags, currentUser: {accountID: RORY_ACCOUNT_ID, email: RORY_EMAIL}, currentUserLocalCurrency: undefined, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -2090,6 +2104,7 @@ describe('actions/Duplicate', () => { targetPolicyTags, currentUser: {accountID: RORY_ACCOUNT_ID, email: RORY_EMAIL}, currentUserLocalCurrency: undefined, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -2261,6 +2276,7 @@ describe('actions/Duplicate', () => { currentUserAccountID: RORY_ACCOUNT_ID, currentUserLogin: RORY_EMAIL, recentWaypoints: [], + delegateAccountID: undefined, ...overrides, }); @@ -2830,6 +2846,7 @@ describe('actions/Duplicate', () => { recentWaypoints: [], currentUser: {accountID: RORY_ACCOUNT_ID, email: RORY_EMAIL}, currentUserLocalCurrency: undefined, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -2945,6 +2962,7 @@ describe('actions/Duplicate', () => { transactionViolations: {}, translate: mockTranslate, recentWaypoints: [], + delegateAccountID: undefined, ...overrides, }); diff --git a/tests/actions/IOUTest/PayMoneyRequestTest.ts b/tests/actions/IOUTest/PayMoneyRequestTest.ts index 4db333dd6bc2..9442e5c0738a 100644 --- a/tests/actions/IOUTest/PayMoneyRequestTest.ts +++ b/tests/actions/IOUTest/PayMoneyRequestTest.ts @@ -164,6 +164,7 @@ describe('actions/IOU/PayMoneyRequest', () => { quickAction: undefined, betas: [CONST.BETAS.ALL], personalDetails: {}, + delegateAccountID: undefined, }); return waitForBatchedUpdates() .then( @@ -435,6 +436,7 @@ describe('actions/IOU/PayMoneyRequest', () => { quickAction: undefined, betas: [CONST.BETAS.ALL], personalDetails: {}, + delegateAccountID: undefined, }); } return waitForBatchedUpdates(); @@ -601,6 +603,7 @@ describe('actions/IOU/PayMoneyRequest', () => { quickAction: undefined, betas: [CONST.BETAS.ALL], personalDetails: {}, + delegateAccountID: undefined, }); } return waitForBatchedUpdates(); @@ -1419,6 +1422,7 @@ describe('actions/IOU/PayMoneyRequest', () => { quickAction: undefined, betas: [CONST.BETAS.ALL], personalDetails: {}, + delegateAccountID: undefined, }); } return waitForBatchedUpdates(); @@ -1545,6 +1549,7 @@ describe('actions/IOU/PayMoneyRequest', () => { quickAction: undefined, betas: [CONST.BETAS.ALL], personalDetails: {}, + delegateAccountID: undefined, }); } await waitForBatchedUpdates(); @@ -1795,6 +1800,7 @@ describe('actions/IOU/PayMoneyRequest', () => { quickAction: undefined, betas: [CONST.BETAS.ALL], personalDetails: {}, + delegateAccountID: undefined, }); } await waitForBatchedUpdates(); diff --git a/tests/actions/IOUTest/ReportWorkflowTest.ts b/tests/actions/IOUTest/ReportWorkflowTest.ts index 6a2d484ecd63..024477e6ec0c 100644 --- a/tests/actions/IOUTest/ReportWorkflowTest.ts +++ b/tests/actions/IOUTest/ReportWorkflowTest.ts @@ -210,6 +210,7 @@ describe('actions/IOU/ReportWorkflow', () => { quickAction: undefined, betas: [CONST.BETAS.ALL], personalDetails: {}, + delegateAccountID: undefined, }); } return waitForBatchedUpdates(); @@ -360,6 +361,7 @@ describe('actions/IOU/ReportWorkflow', () => { quickAction: undefined, betas: [CONST.BETAS.ALL], personalDetails: {}, + delegateAccountID: undefined, }); } return waitForBatchedUpdates(); @@ -440,6 +442,7 @@ describe('actions/IOU/ReportWorkflow', () => { existingTransactionDraft: undefined, betas: [], personalDetails: {}, + delegateAccountID: undefined, }); } return waitForBatchedUpdates(); @@ -487,6 +490,7 @@ describe('actions/IOU/ReportWorkflow', () => { existingTransactionDraft: undefined, betas: [], personalDetails: {}, + delegateAccountID: undefined, }); } return waitForBatchedUpdates(); @@ -715,6 +719,7 @@ describe('actions/IOU/ReportWorkflow', () => { existingTransactionDraft: undefined, betas: [], personalDetails: {}, + delegateAccountID: undefined, }); } return waitForBatchedUpdates(); @@ -762,6 +767,7 @@ describe('actions/IOU/ReportWorkflow', () => { existingTransactionDraft: undefined, betas: [], personalDetails: {}, + delegateAccountID: undefined, }); } return waitForBatchedUpdates(); @@ -959,6 +965,7 @@ describe('actions/IOU/ReportWorkflow', () => { quickAction: undefined, betas: [CONST.BETAS.ALL], personalDetails: {}, + delegateAccountID: undefined, }); } return waitForBatchedUpdates(); @@ -1166,6 +1173,7 @@ describe('actions/IOU/ReportWorkflow', () => { quickAction: undefined, betas: [CONST.BETAS.ALL], personalDetails: {}, + delegateAccountID: undefined, }); } await waitForBatchedUpdates(); diff --git a/tests/actions/IOUTest/SplitTest.ts b/tests/actions/IOUTest/SplitTest.ts index f2b1bd2022e0..2a31f1cbce15 100644 --- a/tests/actions/IOUTest/SplitTest.ts +++ b/tests/actions/IOUTest/SplitTest.ts @@ -2134,6 +2134,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { isSelfTourViewed: false, existingTransactionDraft: undefined, personalDetails: {}, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -2362,6 +2363,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { isSelfTourViewed: false, existingTransactionDraft: undefined, personalDetails: {}, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -2948,6 +2950,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { isSelfTourViewed: false, betas: [CONST.BETAS.ALL], personalDetails: {}, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); await getOnyxData({ @@ -3127,6 +3130,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { isSelfTourViewed: false, betas: [CONST.BETAS.ALL], personalDetails: {}, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); await getOnyxData({ @@ -3311,6 +3315,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { isSelfTourViewed: false, betas: [CONST.BETAS.ALL], personalDetails: {}, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -3505,6 +3510,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { isSelfTourViewed: false, betas: [CONST.BETAS.ALL], personalDetails: {}, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -3764,6 +3770,7 @@ describe('updateSplitTransactions', () => { betas: [CONST.BETAS.ALL], personalDetails: {}, existingTransactionDraft: undefined, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -3898,6 +3905,7 @@ describe('updateSplitTransactions', () => { personalDetails: {}, existingTransactionDraft: undefined, draftTransactionIDs: [], + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -4032,6 +4040,7 @@ describe('updateSplitTransactions', () => { betas: [CONST.BETAS.ALL], personalDetails: {}, existingTransactionDraft: undefined, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -4177,6 +4186,7 @@ describe('updateSplitTransactions', () => { isSelfTourViewed: false, betas: [CONST.BETAS.ALL], personalDetails: {}, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -7485,6 +7495,7 @@ describe('createDistanceRequest', () => { recentWaypoints: recentWaypoints ?? [], personalDetails: distanceMockPersonalDetails, betas: [CONST.BETAS.ALL], + delegateAccountID: undefined, }; } @@ -7495,6 +7506,7 @@ describe('createDistanceRequest', () => { createDistanceRequest({ ...getDefaultDistanceRequestParams({reportID: '123', type: CONST.REPORT.TYPE.EXPENSE}, {amount: 1}, recentWaypoints), participants: [], + delegateAccountID: undefined, }); expect(notifyNewAction).toHaveBeenCalledTimes(0); @@ -7507,6 +7519,7 @@ describe('createDistanceRequest', () => { createDistanceRequest({ ...getDefaultDistanceRequestParams({reportID: '123'}, {amount: 1}, recentWaypoints), participants: [], + delegateAccountID: undefined, }); expect(notifyNewAction).toHaveBeenCalledTimes(1); @@ -7519,6 +7532,7 @@ describe('createDistanceRequest', () => { ...getDefaultDistanceRequestParams({reportID: '123', type: CONST.REPORT.TYPE.EXPENSE}, {amount: 1}, recentWaypoints), iouType: CONST.IOU.TYPE.SPLIT, participants: [], + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -7529,6 +7543,7 @@ describe('createDistanceRequest', () => { iouType: CONST.IOU.TYPE.SPLIT, participants: [], quickAction: {action: CONST.QUICK_ACTIONS.SEND_MONEY, chatReportID: '456'}, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -7548,6 +7563,7 @@ describe('createDistanceRequest', () => { iouType: CONST.IOU.TYPE.SPLIT, policyRecentlyUsedCurrencies: initialCurrencies, personalDetails: distanceMockPersonalDetails, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -7623,6 +7639,7 @@ describe('createDistanceRequest', () => { {accountID: CARLOS_ACCOUNT_ID, login: CARLOS_EMAIL}, {accountID: VIT_ACCOUNT_ID, login: VIT_EMAIL}, ], + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -7680,6 +7697,7 @@ describe('createDistanceRequest', () => { createDistanceRequest({ ...getDefaultDistanceRequestParams(policyExpenseChat, {amount: 2500, merchant: 'Work Trip', comment: 'Business travel', category: testCategory}, recentWaypoints), policyParams: {policy: fakePolicy, policyCategories: fakeCategories}, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -7829,6 +7847,7 @@ describe('createDistanceRequest', () => { createDistanceRequest({ ...getDefaultDistanceRequestParams(testReport, {amount: 1500, comment: 'Billable distance', billable: true}, recentWaypoints), policyParams: {policy: fakePolicy}, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -7863,6 +7882,7 @@ describe('createDistanceRequest', () => { createDistanceRequest({ ...getDefaultDistanceRequestParams(testReport, {comment: 'Tax distance', taxCode: testTaxCode, taxAmount: testTaxAmount}, recentWaypoints), policyParams: {policy: fakePolicy}, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); diff --git a/tests/actions/IOUTest/TrackExpenseTest.ts b/tests/actions/IOUTest/TrackExpenseTest.ts index 208843caddfb..89c60aaf115f 100644 --- a/tests/actions/IOUTest/TrackExpenseTest.ts +++ b/tests/actions/IOUTest/TrackExpenseTest.ts @@ -210,6 +210,7 @@ describe('actions/IOU/TrackExpense', () => { betas: [CONST.BETAS.ALL], isSelfTourViewed: false, currentUserLocalCurrency: undefined, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -332,6 +333,7 @@ describe('actions/IOU/TrackExpense', () => { betas: [CONST.BETAS.ALL], isSelfTourViewed: false, currentUserLocalCurrency: undefined, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); await mockFetch?.resume?.(); @@ -440,6 +442,7 @@ describe('actions/IOU/TrackExpense', () => { betas: [CONST.BETAS.ALL], isSelfTourViewed: false, currentUserLocalCurrency: undefined, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); await mockFetch?.resume?.(); @@ -530,6 +533,7 @@ describe('actions/IOU/TrackExpense', () => { betas: [CONST.BETAS.ALL], isSelfTourViewed: false, currentUserLocalCurrency: undefined, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -584,6 +588,7 @@ describe('actions/IOU/TrackExpense', () => { betas: [CONST.BETAS.ALL], isSelfTourViewed: false, currentUserLocalCurrency: undefined, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -666,6 +671,7 @@ describe('actions/IOU/TrackExpense', () => { betas: [CONST.BETAS.ALL], isSelfTourViewed: false, currentUserLocalCurrency: undefined, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -720,6 +726,7 @@ describe('actions/IOU/TrackExpense', () => { betas: [CONST.BETAS.ALL], isSelfTourViewed: false, currentUserLocalCurrency: undefined, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -806,6 +813,7 @@ describe('actions/IOU/TrackExpense', () => { draftTransactionIDs: [transaction.transactionID], isSelfTourViewed: false, currentUserLocalCurrency: undefined, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -860,6 +868,7 @@ describe('actions/IOU/TrackExpense', () => { draftTransactionIDs: [], isSelfTourViewed: false, currentUserLocalCurrency: undefined, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -944,6 +953,7 @@ describe('actions/IOU/TrackExpense', () => { draftTransactionIDs: [transaction.transactionID], isSelfTourViewed: false, currentUserLocalCurrency: undefined, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -998,6 +1008,7 @@ describe('actions/IOU/TrackExpense', () => { draftTransactionIDs: [], isSelfTourViewed: false, currentUserLocalCurrency: undefined, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -1101,6 +1112,7 @@ describe('actions/IOU/TrackExpense', () => { draftTransactionIDs: [transaction.transactionID], isSelfTourViewed: false, currentUserLocalCurrency: undefined, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -1156,6 +1168,7 @@ describe('actions/IOU/TrackExpense', () => { draftTransactionIDs: [], isSelfTourViewed: false, currentUserLocalCurrency: undefined, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -1219,6 +1232,7 @@ describe('actions/IOU/TrackExpense', () => { betas: [CONST.BETAS.ALL], isSelfTourViewed: false, currentUserLocalCurrency: undefined, + delegateAccountID: undefined, }; } @@ -1442,6 +1456,7 @@ describe('actions/IOU/TrackExpense', () => { betas: [CONST.BETAS.ALL], isSelfTourViewed: false, currentUserLocalCurrency: undefined, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -1532,6 +1547,7 @@ describe('actions/IOU/TrackExpense', () => { betas: [CONST.BETAS.ALL], isSelfTourViewed: false, currentUserLocalCurrency: undefined, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -1653,6 +1669,7 @@ describe('actions/IOU/TrackExpense', () => { trackExpense({ ...getDefaultTrackExpenseParams(undefined, {amount: 3000, merchant: 'Optimistic SelfDM ID Test'}), optimisticChatReportID: optimisticSelfDMReportID, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); const reports = await new Promise>((resolve) => { @@ -1675,6 +1692,7 @@ describe('actions/IOU/TrackExpense', () => { trackExpense({ ...getDefaultTrackExpenseParams(undefined, {amount: 3000, merchant: 'Optimistic Txn ID Test'}), optimisticTransactionID, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -1741,6 +1759,7 @@ describe('actions/IOU/TrackExpense', () => { receipt: {source: 'new-receipt.jpg', name: 'new-receipt.jpg', state: CONST.IOU.RECEIPT_STATE.SCAN_READY}, }), existingTransaction, + delegateAccountID: undefined, }); await mockFetch?.resume?.(); await waitForBatchedUpdates(); @@ -1870,6 +1889,7 @@ describe('actions/IOU/TrackExpense', () => { ...getDefaultTrackExpenseParams(selfDMReport, {amount: 12000, merchant: 'Tour Viewed Merchant'}), isSelfTourViewed: true, currentUserLocalCurrency: undefined, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -1903,6 +1923,7 @@ describe('actions/IOU/TrackExpense', () => { ...getDefaultTrackExpenseParams(selfDMReport, {amount: 9000, merchant: 'Tour Not Viewed Merchant'}), isSelfTourViewed: false, currentUserLocalCurrency: undefined, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -1958,6 +1979,7 @@ describe('actions/IOU/TrackExpense', () => { betas: [CONST.BETAS.ALL], isSelfTourViewed: true, currentUserLocalCurrency: undefined, + delegateAccountID: undefined, }); // Then the result should contain valid track expense data @@ -2004,6 +2026,7 @@ describe('actions/IOU/TrackExpense', () => { betas: [CONST.BETAS.ALL], isSelfTourViewed: false, currentUserLocalCurrency: undefined, + delegateAccountID: undefined, }); // Then the result should contain valid track expense data @@ -2052,6 +2075,7 @@ describe('actions/IOU/TrackExpense', () => { betas: [CONST.BETAS.ALL], isSelfTourViewed: true, currentUserLocalCurrency: undefined, + delegateAccountID: undefined, }); // Then result should be valid @@ -2091,6 +2115,7 @@ describe('actions/IOU/TrackExpense', () => { betas: [CONST.BETAS.ALL], isSelfTourViewed: false, currentUserLocalCurrency: undefined, + delegateAccountID: undefined, }); expect(resultWithoutTourViewed).toBeDefined(); @@ -2151,6 +2176,7 @@ describe('actions/IOU/TrackExpense', () => { quickAction: undefined, betas: [CONST.BETAS.ALL], personalDetails: {}, + delegateAccountID: undefined, }); await mockFetch?.resume?.(); await waitForBatchedUpdates(); @@ -2253,6 +2279,7 @@ describe('actions/IOU/TrackExpense', () => { betas: [CONST.BETAS.ALL], isSelfTourViewed: false, currentUserLocalCurrency: undefined, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -2557,6 +2584,7 @@ describe('actions/IOU/TrackExpense', () => { betas: [CONST.BETAS.ALL], isSelfTourViewed: false, currentUserLocalCurrency: undefined, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -2743,6 +2771,7 @@ describe('actions/IOU/TrackExpense', () => { personalDetails: testPersonalDetails, policyTagList: undefined, betas: [CONST.BETAS.ALL], + delegateAccountID: undefined, }); }).not.toThrow(); }); @@ -2814,6 +2843,7 @@ describe('actions/IOU/TrackExpense', () => { personalDetails: testPersonalDetails, policyTagList: undefined, betas: [CONST.BETAS.ALL], + delegateAccountID: undefined, }); }).not.toThrow(); }); @@ -2855,6 +2885,7 @@ describe('actions/IOU/TrackExpense', () => { personalDetails: undefined, policyTagList: undefined, betas: [CONST.BETAS.ALL], + delegateAccountID: undefined, }); }).not.toThrow(); }); @@ -2896,6 +2927,7 @@ describe('actions/IOU/TrackExpense', () => { personalDetails: undefined, policyTagList: undefined, betas: [CONST.BETAS.ALL], + delegateAccountID: undefined, }); }).not.toThrow(); }); diff --git a/tests/actions/TransactionTest.ts b/tests/actions/TransactionTest.ts index 270bdf2ed1fb..00d3d7a610f9 100644 --- a/tests/actions/TransactionTest.ts +++ b/tests/actions/TransactionTest.ts @@ -236,6 +236,7 @@ describe('actions/Transaction', () => { draftTransactionIDs: [], isSelfTourViewed: false, currentUserLocalCurrency: undefined, + delegateAccountID: undefined, }); await getOnyxData({ key: ONYXKEYS.COLLECTION.TRANSACTION, @@ -404,6 +405,7 @@ describe('actions/Transaction', () => { quickAction: undefined, betas: [CONST.BETAS.ALL], personalDetails: {}, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); await getOnyxData({ @@ -583,6 +585,7 @@ describe('actions/Transaction', () => { quickAction: undefined, betas: [CONST.BETAS.ALL], personalDetails: {}, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); await getOnyxData({ @@ -767,6 +770,7 @@ describe('actions/Transaction', () => { quickAction: undefined, betas: [CONST.BETAS.ALL], personalDetails: {}, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -961,6 +965,7 @@ describe('actions/Transaction', () => { quickAction: undefined, betas: [CONST.BETAS.ALL], personalDetails: {}, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); diff --git a/tests/ui/UnreadIndicatorsTest.tsx b/tests/ui/UnreadIndicatorsTest.tsx index b4743400a1a0..82d921a945bf 100644 --- a/tests/ui/UnreadIndicatorsTest.tsx +++ b/tests/ui/UnreadIndicatorsTest.tsx @@ -803,6 +803,7 @@ describe('Unread Indicators', () => { betas: [CONST.BETAS.ALL], isSelfTourViewed: false, currentUserLocalCurrency: undefined, + delegateAccountID: undefined, }); await waitForBatchedUpdates(); diff --git a/tests/unit/GoogleTagManagerTest.tsx b/tests/unit/GoogleTagManagerTest.tsx index 2eb48d7da8f1..667b80a065b9 100644 --- a/tests/unit/GoogleTagManagerTest.tsx +++ b/tests/unit/GoogleTagManagerTest.tsx @@ -290,6 +290,7 @@ describe('GoogleTagManagerTest', () => { betas: [CONST.BETAS.ALL], isSelfTourViewed: false, currentUserLocalCurrency: undefined, + delegateAccountID: undefined, }); await waitForBatchedUpdatesWithAct(); From f5dfbdd54136f7d1497b6d1b081131948583c27d Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Sun, 5 Jul 2026 07:07:39 +0530 Subject: [PATCH 2/4] Pass delegateAccountID from remaining IOU page callers Signed-off-by: krishna2323 --- src/pages/Share/SubmitDetailsPage.tsx | 8 ++++---- src/pages/iou/request/step/AmountSubmission.ts | 6 ++---- .../step/IOURequestStepDistanceGPS/index.native.tsx | 5 +++-- .../iou/request/step/IOURequestStepDistanceManual.tsx | 3 +-- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/pages/Share/SubmitDetailsPage.tsx b/src/pages/Share/SubmitDetailsPage.tsx index 3dd8e5141ebf..09cb5a5eba61 100644 --- a/src/pages/Share/SubmitDetailsPage.tsx +++ b/src/pages/Share/SubmitDetailsPage.tsx @@ -5,6 +5,7 @@ import MoneyRequestConfirmationList from '@components/MoneyRequestConfirmationLi import ScreenWrapper from '@components/ScreenWrapper'; import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; +import useDelegateAccountID from '@hooks/useDelegateAccountID'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; import useOnyx from '@hooks/useOnyx'; @@ -74,6 +75,7 @@ function SubmitDetailsPage({ }: ShareDetailsPageProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); + const delegateAccountID = useDelegateAccountID(); const [unknownUserDetails] = useOnyx(ONYXKEYS.SHARE_UNKNOWN_USER_DETAILS); const [personalDetails] = useOnyx(`${ONYXKEYS.PERSONAL_DETAILS_LIST}`); const report: OnyxEntry = useReportOrReportDraft(reportOrAccountID); @@ -289,8 +291,7 @@ function SubmitDetailsPage({ isSelfTourViewed, optimisticTransactionID, currentUserLocalCurrency: currentUserPersonalDetails.localCurrencyCode ?? CONST.CURRENCY.USD, - // TODO: delegateAccountID will be threaded in PR 10b (https://github.com/Expensify/App/issues/66425) - delegateAccountID: undefined, + delegateAccountID, }); } else { const existingTransactionDraft = existingTransactionID ? transactionDrafts?.[existingTransactionID] : undefined; @@ -335,8 +336,7 @@ function SubmitDetailsPage({ betas, personalDetails, optimisticTransactionID, - // TODO: delegateAccountID will be threaded in PR 10b (https://github.com/Expensify/App/issues/66425) - delegateAccountID: undefined, + delegateAccountID, }); } cleanupAndNavigateAfterExpenseCreate({ diff --git a/src/pages/iou/request/step/AmountSubmission.ts b/src/pages/iou/request/step/AmountSubmission.ts index a274965c987a..2003cbc7afc4 100644 --- a/src/pages/iou/request/step/AmountSubmission.ts +++ b/src/pages/iou/request/step/AmountSubmission.ts @@ -389,8 +389,7 @@ function submitAmount({ isSelfTourViewed, optimisticChatReportID, optimisticTransactionID, - // TODO: delegateAccountID will be threaded in PR 10b (https://github.com/Expensify/App/issues/66425) - delegateAccountID: undefined, + delegateAccountID, }); } else { const existingTransactionDraft = existingTransactionID ? transactionDrafts?.[existingTransactionID] : undefined; @@ -425,8 +424,7 @@ function submitAmount({ personalDetails: allPersonalDetails, optimisticChatReportID, optimisticTransactionID, - // TODO: delegateAccountID will be threaded in PR 10b (https://github.com/Expensify/App/issues/66425) - delegateAccountID: undefined, + delegateAccountID, }); } cleanupAfterSkipConfirmSubmit(overrides.shouldHandleNavigation, { diff --git a/src/pages/iou/request/step/IOURequestStepDistanceGPS/index.native.tsx b/src/pages/iou/request/step/IOURequestStepDistanceGPS/index.native.tsx index ea0bc47f3adb..b3419b494ab8 100644 --- a/src/pages/iou/request/step/IOURequestStepDistanceGPS/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistanceGPS/index.native.tsx @@ -4,6 +4,7 @@ import type {Coordinate} from '@components/MapView/MapViewTypes'; import withCurrentUserPersonalDetails from '@components/withCurrentUserPersonalDetails'; import useDefaultExpensePolicy from '@hooks/useDefaultExpensePolicy'; +import useDelegateAccountID from '@hooks/useDelegateAccountID'; import useIsInLandscapeMode from '@hooks/useIsInLandscapeMode'; import useLocalize from '@hooks/useLocalize'; import useOnyx from '@hooks/useOnyx'; @@ -55,6 +56,7 @@ function IOURequestStepDistanceGPS({ currentUserPersonalDetails, }: IOURequestStepDistanceGPSProps) { const styles = useThemeStyles(); + const delegateAccountID = useDelegateAccountID(); const {translate} = useLocalize(); const {isBetaEnabled} = usePermissions(); @@ -165,8 +167,7 @@ function IOURequestStepDistanceGPS({ optimisticTransactionID, optimisticChatReportID, reportDraft, - // TODO: delegateAccountID will be threaded in PR 10b (https://github.com/Expensify/App/issues/66425) - delegateAccountID: undefined, + delegateAccountID, }); }; diff --git a/src/pages/iou/request/step/IOURequestStepDistanceManual.tsx b/src/pages/iou/request/step/IOURequestStepDistanceManual.tsx index 64ad5c11271f..abec21e5f726 100644 --- a/src/pages/iou/request/step/IOURequestStepDistanceManual.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistanceManual.tsx @@ -285,8 +285,7 @@ function IOURequestStepDistanceManual({ optimisticTransactionID, optimisticChatReportID, reportDraft, - // TODO: delegateAccountID will be threaded in PR 10b (https://github.com/Expensify/App/issues/66425) - delegateAccountID: undefined, + delegateAccountID, }); }; From 7e3ede2259284960a78fa78478a67e7492754b69 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Sun, 5 Jul 2026 08:27:42 +0530 Subject: [PATCH 3/4] Add delegateAccountID forwarding tests for requestMoney and trackExpense Signed-off-by: krishna2323 --- tests/actions/IOU/RequestMoneyTest.ts | 60 +++++++++++++++++++++++ tests/actions/IOUTest/TrackExpenseTest.ts | 22 +++++++++ 2 files changed, 82 insertions(+) diff --git a/tests/actions/IOU/RequestMoneyTest.ts b/tests/actions/IOU/RequestMoneyTest.ts index 2fc508d46252..9e8bcb6aded1 100644 --- a/tests/actions/IOU/RequestMoneyTest.ts +++ b/tests/actions/IOU/RequestMoneyTest.ts @@ -2425,6 +2425,66 @@ describe('actions/IOU', () => { ) .then(mockFetch?.resume); }); + + describe('delegateAccountID forwarding', () => { + it('sets delegateAccountID on the IOU action when delegateAccountID is provided', async () => { + const DELEGATE_ACCOUNT_ID = 999; + mockFetch?.pause?.(); + + requestMoney({ + report: {reportID: ''}, + participantParams: { + payeeEmail: RORY_EMAIL, + payeeAccountID: RORY_ACCOUNT_ID, + participant: {login: CARLOS_EMAIL, accountID: CARLOS_ACCOUNT_ID}, + }, + transactionParams: { + amount: 10000, + attendees: [], + currency: CONST.CURRENCY.USD, + created: format(new Date(), CONST.DATE.FNS_FORMAT_STRING), + merchant: 'Test', + comment: 'delegate test', + }, + shouldGenerateTransactionThreadReport: true, + isASAPSubmitBetaEnabled: false, + transactionViolations: {}, + currentUserAccountIDParam: RORY_ACCOUNT_ID, + currentUserEmailParam: RORY_EMAIL, + policyRecentlyUsedCurrencies: [], + existingTransactionDraft: undefined, + draftTransactionIDs: [], + isSelfTourViewed: false, + quickAction: undefined, + betas: [CONST.BETAS.ALL], + personalDetails: {}, + delegateAccountID: DELEGATE_ACCOUNT_ID, + }); + await waitForBatchedUpdates(); + + let iouReport: Report | undefined; + await getOnyxData({ + key: ONYXKEYS.COLLECTION.REPORT, + waitForCollectionCallback: true, + callback: (allReports) => { + iouReport = Object.values(allReports ?? {}).find((report) => report?.type === CONST.REPORT.TYPE.IOU); + }, + }); + expect(iouReport).toBeTruthy(); + + let iouAction: ReportAction | undefined; + await getOnyxData({ + key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport?.reportID}`, + waitForCollectionCallback: true, + callback: (reportActions) => { + iouAction = Object.values(reportActions ?? {}).find((action) => isMoneyRequestAction(action)); + }, + }); + expect(iouAction?.delegateAccountID).toBe(DELEGATE_ACCOUNT_ID); + + await mockFetch?.resume?.(); + }); + }); }); describe('should have valid parameters', () => { diff --git a/tests/actions/IOUTest/TrackExpenseTest.ts b/tests/actions/IOUTest/TrackExpenseTest.ts index 89c60aaf115f..649dddb670c2 100644 --- a/tests/actions/IOUTest/TrackExpenseTest.ts +++ b/tests/actions/IOUTest/TrackExpenseTest.ts @@ -2122,6 +2122,28 @@ describe('actions/IOU/TrackExpense', () => { expect(resultWithoutTourViewed.chatReport).toBeDefined(); expect(resultWithoutTourViewed.transaction).toBeDefined(); }); + + describe('delegateAccountID forwarding', () => { + it('sets delegateAccountID on the IOU action when delegateAccountID is provided', async () => { + const DELEGATE_ACCOUNT_ID = 999; + const selfDMReport: Report = { + ...createRandomReport(1, CONST.REPORT.CHAT_TYPE.SELF_DM), + reportID: 'selfDM-delegate-forward', + }; + + await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${selfDMReport.reportID}`, selfDMReport); + + trackExpense({ + ...getDefaultTrackExpenseParams(selfDMReport), + delegateAccountID: DELEGATE_ACCOUNT_ID, + }); + await waitForBatchedUpdates(); + + const reportActions = await getOnyxValue(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${selfDMReport.reportID}`); + const iouAction = Object.values(reportActions ?? {}).find((action) => isMoneyRequestAction(action)); + expect(iouAction?.delegateAccountID).toBe(DELEGATE_ACCOUNT_ID); + }); + }); }); describe('requestMoney', () => { From e3a53e258c7dcabe2a277f9ba7f205931ff89a9b Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Sun, 5 Jul 2026 09:08:39 +0530 Subject: [PATCH 4/4] fix ESLint. Signed-off-by: krishna2323 --- tests/actions/IOU/RequestMoneyTest.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/actions/IOU/RequestMoneyTest.ts b/tests/actions/IOU/RequestMoneyTest.ts index 9e8bcb6aded1..f8c8be057fa3 100644 --- a/tests/actions/IOU/RequestMoneyTest.ts +++ b/tests/actions/IOU/RequestMoneyTest.ts @@ -2470,16 +2470,16 @@ describe('actions/IOU', () => { iouReport = Object.values(allReports ?? {}).find((report) => report?.type === CONST.REPORT.TYPE.IOU); }, }); - expect(iouReport).toBeTruthy(); - - let iouAction: ReportAction | undefined; - await getOnyxData({ - key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport?.reportID}`, - waitForCollectionCallback: true, - callback: (reportActions) => { - iouAction = Object.values(reportActions ?? {}).find((action) => isMoneyRequestAction(action)); - }, - }); + const iouReportID = iouReport?.reportID; + expect(iouReportID).toBeTruthy(); + if (!iouReportID) { + throw new Error('Expected IOU report to be created'); + } + + const reportActions = await getOnyxValue(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReportID}`); + const iouAction = Object.values(reportActions ?? {}).find((reportAction): reportAction is ReportAction => + isMoneyRequestAction(reportAction), + ); expect(iouAction?.delegateAccountID).toBe(DELEGATE_ACCOUNT_ID); await mockFetch?.resume?.();