From d054eb4c7dadb2e1a2096722b60ace45abf7ab0e Mon Sep 17 00:00:00 2001 From: Maruf Sharifi Date: Mon, 3 Aug 2026 15:44:01 +0430 Subject: [PATCH 1/6] Inject phone formatter into MoneyRequestBuilder --- src/components/AddExistingExpenseFooter.tsx | 3 +- src/hooks/useDeleteTransactions.ts | 4 ++ src/libs/IOUAmountSubmission.ts | 5 +- src/libs/actions/IOU/Duplicate.ts | 2 + src/libs/actions/IOU/MoneyRequest.ts | 5 +- src/libs/actions/IOU/MoneyRequestBuilder.ts | 9 +++- src/libs/actions/IOU/PerDiem.ts | 1 + src/libs/actions/IOU/Split.ts | 4 ++ .../actions/IOU/SplitTransactionUpdate.ts | 5 ++ src/libs/actions/IOU/TrackExpense.ts | 7 +++ src/pages/Share/SubmitDetailsPage.tsx | 3 +- src/pages/iou/SplitExpensePage.tsx | 3 +- .../iou/request/step/IOURequestStepAmount.tsx | 3 +- .../components/ScanSkipConfirmation.tsx | 1 + .../step/confirmation/useExpenseSubmission.ts | 1 + .../IOU/BuildOnyxDataForMoneyRequestTest.ts | 44 ++++++++++++++++- .../IOU/GetMoneyRequestInformationTest.ts | 2 + tests/actions/IOU/RequestMoneyTest.ts | 24 ++++++++++ tests/actions/IOU/SplitReportTotalsTest.ts | 1 + .../IOUTest/CreateExpenseByTypeTest.ts | 2 + .../actions/IOUTest/DeleteMoneyRequestTest.ts | 7 ++- tests/actions/IOUTest/PayMoneyRequestTest.ts | 8 +++- tests/actions/IOUTest/ReportWorkflowTest.ts | 8 ++++ tests/actions/IOUTest/SplitSelfDMTest.ts | 8 +++- tests/actions/IOUTest/SplitTest.ts | 47 +++++++++++++++++++ tests/actions/IOUTest/TrackExpenseTest.ts | 4 ++ tests/actions/TransactionTest.ts | 10 +++- tests/unit/IOUAmountSubmissionTest.ts | 3 +- 28 files changed, 211 insertions(+), 13 deletions(-) diff --git a/src/components/AddExistingExpenseFooter.tsx b/src/components/AddExistingExpenseFooter.tsx index 3f01656d9b63..fb4dd1f52a96 100644 --- a/src/components/AddExistingExpenseFooter.tsx +++ b/src/components/AddExistingExpenseFooter.tsx @@ -47,7 +47,7 @@ type AddExistingExpenseFooterProps = { }; function AddExistingExpenseFooter({selectedIds, report, reportToConfirm, reportNextStep, policy, policyCategories, errorMessage, setErrorMessage}: AddExistingExpenseFooterProps) { - const {translate} = useLocalize(); + const {translate, formatPhoneNumber} = useLocalize(); const styles = useThemeStyles(); const {isBetaEnabled} = usePermissions(); const isASAPSubmitBetaEnabled = isBetaEnabled(CONST.BETAS.ASAP_SUBMIT); @@ -94,6 +94,7 @@ function AddExistingExpenseFooter({selectedIds, report, reportToConfirm, reportN selfDMReportActions, delegateAccountID, isTrackIntentUser, + formatPhoneNumber, }); } else { changeTransactionsReport({ diff --git a/src/hooks/useDeleteTransactions.ts b/src/hooks/useDeleteTransactions.ts index 6dc488f740c1..82fd659fdb80 100644 --- a/src/hooks/useDeleteTransactions.ts +++ b/src/hooks/useDeleteTransactions.ts @@ -33,6 +33,7 @@ import {useCallback} from 'react'; import useCurrentUserPersonalDetails from './useCurrentUserPersonalDetails'; import useDelegateAccountID from './useDelegateAccountID'; import useEnvironment from './useEnvironment'; +import useLocalize from './useLocalize'; import useNetwork from './useNetwork'; import useOnyx from './useOnyx'; import usePermissions from './usePermissions'; @@ -102,6 +103,7 @@ function useDeleteTransactions({report, reportActions, policy}: UseDeleteTransac const restrictedActionPolicyID = useRestrictedActionPolicyID(policy); const {isOffline} = useNetwork(); const {isProduction} = useEnvironment(); + const {formatPhoneNumber} = useLocalize(); const getSplitExpenseEditTransactionOnDelete = useCallback( (transactionIDs: string[]): Transaction | undefined => { @@ -333,6 +335,7 @@ function useDeleteTransactions({report, reportActions, policy}: UseDeleteTransac isOffline, delegateAccountID, isTrackIntentUser, + formatPhoneNumber, }); } @@ -409,6 +412,7 @@ function useDeleteTransactions({report, reportActions, policy}: UseDeleteTransac personalPolicy?.outputCurrency, delegateAccountID, isTrackIntentUser, + formatPhoneNumber, ], ); diff --git a/src/libs/IOUAmountSubmission.ts b/src/libs/IOUAmountSubmission.ts index f677618c0b83..af8e49c8c552 100644 --- a/src/libs/IOUAmountSubmission.ts +++ b/src/libs/IOUAmountSubmission.ts @@ -1,4 +1,4 @@ -import type {LocalizedTranslate} from '@components/LocaleContextProvider'; +import type {LocaleContextProps, LocalizedTranslate} from '@components/LocaleContextProvider'; import CONST from '@src/CONST'; import type {IOUAction, IOUType} from '@src/CONST'; @@ -78,6 +78,7 @@ type SubmitAmountArgs = { amount: string; paymentMethod?: PaymentMethodType; translate: LocalizedTranslate; + formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; // Submit-time Onyx data — supplied by the screen via AmountSubmitDataSync so this module owns no subscriptions. allPersonalDetails: OnyxEntry; @@ -325,6 +326,7 @@ function submitSkipConfirmationExpense(args: SubmitAmountArgs, ctx: SubmitAmount action, currentUserPersonalDetails, isTrackIntentUser, + formatPhoneNumber, } = args; const {currentUserAccountID, currentUserEmail, existingTransactionID, isASAPSubmitBetaEnabled, newAmount: backendAmount} = ctx; @@ -408,6 +410,7 @@ function submitSkipConfirmationExpense(args: SubmitAmountArgs, ctx: SubmitAmount optimisticTransactionID, delegateAccountID, isTrackIntentUser, + formatPhoneNumber, }); } cleanupAfterSkipConfirmSubmit(overrides.shouldHandleNavigation, { diff --git a/src/libs/actions/IOU/Duplicate.ts b/src/libs/actions/IOU/Duplicate.ts index 8fc4f5b9e09b..40d9bf57c86e 100644 --- a/src/libs/actions/IOU/Duplicate.ts +++ b/src/libs/actions/IOU/Duplicate.ts @@ -853,6 +853,7 @@ function duplicateExpenseTransaction({ shouldDeferAutoSubmit, isTrackIntentUser, delegateAccountID, + formatPhoneNumber, }; // If no workspace is provided the expense should be unreported @@ -1067,6 +1068,7 @@ function duplicateReport({ shouldDeferAutoSubmit: !isLastExpense, isTrackIntentUser, delegateAccountID, + formatPhoneNumber, }; const result = createExpenseByType({ diff --git a/src/libs/actions/IOU/MoneyRequest.ts b/src/libs/actions/IOU/MoneyRequest.ts index 3525bd7b0407..9cdd98059f21 100644 --- a/src/libs/actions/IOU/MoneyRequest.ts +++ b/src/libs/actions/IOU/MoneyRequest.ts @@ -1,4 +1,4 @@ -import type {LocalizedTranslate} from '@components/LocaleContextProvider'; +import type {LocaleContextProps, LocalizedTranslate} from '@components/LocaleContextProvider'; import {WRITE_COMMANDS} from '@libs/API/types'; import DateUtils from '@libs/DateUtils'; @@ -100,6 +100,7 @@ type CreateTransactionParams = { currentUserLocalCurrency: string | undefined; isTrackIntentUser: boolean | undefined; delegateAccountID: number | undefined; + formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; }; function createTransaction({ @@ -130,6 +131,7 @@ function createTransaction({ currentUserLocalCurrency, isTrackIntentUser, delegateAccountID, + formatPhoneNumber, }: CreateTransactionParams) { const draftTransactionIDs = Object.keys(allTransactionDrafts ?? {}); @@ -236,6 +238,7 @@ function createTransaction({ optimisticTransactionID, isTrackIntentUser, delegateAccountID, + formatPhoneNumber, }); } } diff --git a/src/libs/actions/IOU/MoneyRequestBuilder.ts b/src/libs/actions/IOU/MoneyRequestBuilder.ts index 09668a66b821..0776938f2f1e 100644 --- a/src/libs/actions/IOU/MoneyRequestBuilder.ts +++ b/src/libs/actions/IOU/MoneyRequestBuilder.ts @@ -1,9 +1,10 @@ +import type {LocaleContextProps} from '@components/LocaleContextProvider'; + import DateUtils from '@libs/DateUtils'; import {getMicroSecondOnyxErrorObject, getMicroSecondOnyxErrorWithTranslationKey} from '@libs/ErrorUtils'; import {isLocalFile} from '@libs/fileDownload/FileUtils'; import type {MinimalTransaction} from '@libs/Formula'; import {updateIOUOwnerAndTotal} from '@libs/IOUUtils'; -import {formatPhoneNumber} from '@libs/LocalePhoneNumber'; import {translateLocal} from '@libs/Localize'; import {buildNextStepNew, buildOptimisticNextStep} from '@libs/NextStepUtils'; import {rand64} from '@libs/NumberUtils'; @@ -190,6 +191,7 @@ type RequestMoneyInformation = { shouldDeferAutoSubmit?: boolean; delegateAccountID: number | undefined; isTrackIntentUser: boolean | undefined; + formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; }; type MoneyRequestInformationParams = { @@ -225,6 +227,7 @@ type MoneyRequestInformationParams = { personalDetails: OnyxEntry; isTrackIntentUser: boolean | undefined; delegateAccountID: number | undefined; + formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; }; type MoneyRequestOptimisticParams = { @@ -279,6 +282,7 @@ type BuildOnyxDataForMoneyRequestParams = { /** The selfDM report ID for split transactions */ selfDMReportID?: string; isTrackIntentUser: boolean | undefined; + formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; }; type BuildOnyxDataForTestDriveIOUParams = { @@ -441,6 +445,7 @@ function buildOnyxDataForMoneyRequest(moneyRequestParams: BuildOnyxDataForMoneyR isReverseSplitOperation, selfDMReportID, isTrackIntentUser, + formatPhoneNumber, } = moneyRequestParams; const {policy, policyCategories, policyTagList} = policyParams; const { @@ -1292,6 +1297,7 @@ function getMoneyRequestInformation(moneyRequestInformation: MoneyRequestInforma betas, delegateAccountID, isTrackIntentUser, + formatPhoneNumber, } = moneyRequestInformation; const {payeeAccountID = currentUserAccountIDParam, payeeEmail = currentUserEmailParam, participant} = participantParams; const {policy, policyCategories, policyTagList, policyRecentlyUsedCategories, policyRecentlyUsedTags} = policyParams; @@ -1701,6 +1707,7 @@ function getMoneyRequestInformation(moneyRequestInformation: MoneyRequestInforma isSelfDMSplit, selfDMReportID, isTrackIntentUser, + formatPhoneNumber, }); return { diff --git a/src/libs/actions/IOU/PerDiem.ts b/src/libs/actions/IOU/PerDiem.ts index 5785948aabda..ea1432a0a4e6 100644 --- a/src/libs/actions/IOU/PerDiem.ts +++ b/src/libs/actions/IOU/PerDiem.ts @@ -578,6 +578,7 @@ function getPerDiemExpenseInformation(perDiemExpenseInformation: PerDiemExpenseI personalDetails, delegateAccountID, isTrackIntentUser, + formatPhoneNumber, }); return { diff --git a/src/libs/actions/IOU/Split.ts b/src/libs/actions/IOU/Split.ts index 689ce2f0613d..67c30d3aec1d 100644 --- a/src/libs/actions/IOU/Split.ts +++ b/src/libs/actions/IOU/Split.ts @@ -911,6 +911,7 @@ function completeSplitBill({ delegateAccountID, isTrackIntentUser, sessionEmail, + formatPhoneNumber, }: CompleteSplitBillActionParams) { if (!reportAction) { return; @@ -1159,6 +1160,7 @@ function completeSplitBill({ personalDetails, delegateAccountID, isTrackIntentUser, + formatPhoneNumber, }); splits.push({ @@ -1899,6 +1901,7 @@ function createSplitsAndOnyxData({ personalDetails, delegateAccountID, isTrackIntentUser, + formatPhoneNumber, }); const individualSplit = { @@ -2170,6 +2173,7 @@ function createDistanceRequest(distanceRequestInformation: CreateDistanceRequest delegateAccountID, isTrackIntentUser, optimisticChatReportID, + formatPhoneNumber, }); onyxData = moneyRequestOnyxData; diff --git a/src/libs/actions/IOU/SplitTransactionUpdate.ts b/src/libs/actions/IOU/SplitTransactionUpdate.ts index b63a1160807f..4093d531bef1 100644 --- a/src/libs/actions/IOU/SplitTransactionUpdate.ts +++ b/src/libs/actions/IOU/SplitTransactionUpdate.ts @@ -1,3 +1,4 @@ +import type {LocaleContextProps} from '@components/LocaleContextProvider'; import type {SearchActionsContextValue, SearchStateContextValue} from '@components/Search/types'; import {write as apiWrite} from '@libs/API'; @@ -119,6 +120,7 @@ type UpdateSplitTransactionsParams = { isOffline: boolean; delegateAccountID: number | undefined; isTrackIntentUser: boolean | undefined; + formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; }; /** @@ -200,6 +202,7 @@ function updateSplitTransactions({ isOffline, delegateAccountID, isTrackIntentUser, + formatPhoneNumber, }: UpdateSplitTransactionsParams) { const parentTransactionReport = getReportOrDraftReport(transactionReport?.parentReportID); // For selfDM-origin splits the caller can't resolve a real `expenseReport` (the draft/source @@ -662,6 +665,7 @@ function updateSplitTransactions({ personalDetails, delegateAccountID, isTrackIntentUser, + formatPhoneNumber, } as MoneyRequestInformationParams; if (isReverseSplitOperation) { @@ -776,6 +780,7 @@ function updateSplitTransactions({ personalDetails, delegateAccountID, isTrackIntentUser, + formatPhoneNumber, }); let updateMoneyRequestParamsOnyxData: OnyxData = {}; diff --git a/src/libs/actions/IOU/TrackExpense.ts b/src/libs/actions/IOU/TrackExpense.ts index b0378ebf0c5f..632d5cbfb07a 100644 --- a/src/libs/actions/IOU/TrackExpense.ts +++ b/src/libs/actions/IOU/TrackExpense.ts @@ -1,5 +1,7 @@ import ReceiptGeneric from '@assets/images/receipt-generic.png'; +import type {LocaleContextProps} from '@components/LocaleContextProvider'; + import * as API from '@libs/API'; import type {AddTrackedExpenseToPolicyParams, CreateWorkspaceParams, DeleteMoneyRequestParams, RequestMoneyParams, ShareTrackedExpenseParams, TrackExpenseParams} from '@libs/API/parameters'; import {WRITE_COMMANDS} from '@libs/API/types'; @@ -1653,6 +1655,7 @@ function requestMoney(requestMoneyInformation: RequestMoneyInformation): {iouRep shouldDeferAutoSubmit, delegateAccountID, isTrackIntentUser, + formatPhoneNumber, } = requestMoneyInformation; const {payeeAccountID} = participantParams; const parsedComment = getParsedComment(transactionParams.comment ?? ''); @@ -1763,6 +1766,7 @@ function requestMoney(requestMoneyInformation: RequestMoneyInformation): {iouRep personalDetails, delegateAccountID, isTrackIntentUser, + formatPhoneNumber, }); const activeReportID = isMoneyRequestReport ? report?.reportID : chatReport.reportID; @@ -1954,6 +1958,7 @@ function convertBulkTrackedExpensesToIOU({ selfDMReportActions, delegateAccountID, isTrackIntentUser, + formatPhoneNumber, }: { transactions: OnyxTypes.Transaction[]; iouReport: OnyxEntry; @@ -1970,6 +1975,7 @@ function convertBulkTrackedExpensesToIOU({ selfDMReportActions: OnyxEntry; delegateAccountID: number | undefined; isTrackIntentUser: boolean | undefined; + formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; }) { const iouReportID = iouReport?.reportID; @@ -2090,6 +2096,7 @@ function convertBulkTrackedExpensesToIOU({ }, delegateAccountID, isTrackIntentUser, + formatPhoneNumber, }); const isDistanceRequest = isDistanceRequestTransactionUtils(transaction); diff --git a/src/pages/Share/SubmitDetailsPage.tsx b/src/pages/Share/SubmitDetailsPage.tsx index c4f8704f5d46..a51089f70b17 100644 --- a/src/pages/Share/SubmitDetailsPage.tsx +++ b/src/pages/Share/SubmitDetailsPage.tsx @@ -77,7 +77,7 @@ function SubmitDetailsPage({ }, }: ShareDetailsPageProps) { const styles = useThemeStyles(); - const {translate} = useLocalize(); + const {translate, formatPhoneNumber} = useLocalize(); const delegateAccountID = useDelegateAccountID(); const [unknownUserDetails] = useOnyx(ONYXKEYS.SHARE_UNKNOWN_USER_DETAILS); const [personalDetails] = useOnyx(`${ONYXKEYS.PERSONAL_DETAILS_LIST}`); @@ -375,6 +375,7 @@ function SubmitDetailsPage({ optimisticTransactionID, isTrackIntentUser, delegateAccountID, + formatPhoneNumber, }); } cleanupAndNavigateAfterExpenseCreate({ diff --git a/src/pages/iou/SplitExpensePage.tsx b/src/pages/iou/SplitExpensePage.tsx index 9bbd04a3196f..f1149e9a7b40 100644 --- a/src/pages/iou/SplitExpensePage.tsx +++ b/src/pages/iou/SplitExpensePage.tsx @@ -89,7 +89,7 @@ const TAB_NAVIGATOR_HEIGHT_LANDSCAPE = variables.tabSelectorButtonHeight + varia function SplitExpensePage({route}: SplitExpensePageProps) { const styles = useThemeStyles(); - const {translate} = useLocalize(); + const {translate, formatPhoneNumber} = useLocalize(); const delegateAccountID = useDelegateAccountID(); const {reportID, transactionID, splitExpenseTransactionID, backTo} = route.params; @@ -402,6 +402,7 @@ function SplitExpensePage({route}: SplitExpensePageProps) { isOffline, delegateAccountID, isTrackIntentUser, + formatPhoneNumber, }); }; diff --git a/src/pages/iou/request/step/IOURequestStepAmount.tsx b/src/pages/iou/request/step/IOURequestStepAmount.tsx index 8b4043df52f4..099638f4d8d8 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.tsx +++ b/src/pages/iou/request/step/IOURequestStepAmount.tsx @@ -72,7 +72,7 @@ function IOURequestStepAmount({ transaction, shouldKeepUserInput = false, }: IOURequestStepAmountProps) { - const {translate} = useLocalize(); + const {translate, formatPhoneNumber} = useLocalize(); const {getCurrencyDecimals} = useCurrencyListActions(); const currentUserPersonalDetails = useCurrentUserPersonalDetails(); const [isCurrencyPickerVisible, setIsCurrencyPickerVisible] = useState(false); @@ -251,6 +251,7 @@ function IOURequestStepAmount({ navigateBack: saveAndNavigateBack, amount, paymentMethod, + formatPhoneNumber, isTrackIntentUser, policyTags, reportPolicyTags, diff --git a/src/pages/iou/request/step/IOURequestStepScan/components/ScanSkipConfirmation.tsx b/src/pages/iou/request/step/IOURequestStepScan/components/ScanSkipConfirmation.tsx index 7af6a2e499c5..5ba16ce8d102 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/components/ScanSkipConfirmation.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/components/ScanSkipConfirmation.tsx @@ -304,6 +304,7 @@ function ScanSkipConfirmation({report, action, iouType, reportID, transactionID, currentUserLocalCurrency: currentUserPersonalDetails.localCurrencyCode ?? CONST.CURRENCY.USD, isTrackIntentUser, delegateAccountID, + formatPhoneNumber, }; 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 9e7b8973722a..b9524de75b64 100644 --- a/src/pages/iou/request/step/confirmation/useExpenseSubmission.ts +++ b/src/pages/iou/request/step/confirmation/useExpenseSubmission.ts @@ -538,6 +538,7 @@ function useExpenseSubmission(params: UseExpenseSubmissionParams) { personalDetails, isTrackIntentUser, delegateAccountID, + formatPhoneNumber, }); existingIOUReport = iouReport; if (!iouReport) { diff --git a/tests/actions/IOU/BuildOnyxDataForMoneyRequestTest.ts b/tests/actions/IOU/BuildOnyxDataForMoneyRequestTest.ts index 9517afe347c5..2d53ea6ce6d1 100644 --- a/tests/actions/IOU/BuildOnyxDataForMoneyRequestTest.ts +++ b/tests/actions/IOU/BuildOnyxDataForMoneyRequestTest.ts @@ -1,4 +1,4 @@ -import {buildOnyxDataForMoneyRequest} from '@libs/actions/IOU/MoneyRequestBuilder'; +import {buildOnyxDataForMoneyRequest, getMoneyRequestInformation} from '@libs/actions/IOU/MoneyRequestBuilder'; import {getOriginalMessage} from '@libs/ReportActionsUtils'; import type {OptimisticCreatedReportAction, OptimisticIOUReportAction} from '@libs/ReportUtils'; @@ -9,6 +9,7 @@ import type {Report, ReportAction, Transaction} from '@src/types/onyx'; import Onyx from 'react-native-onyx'; import {createSelfDM} from '../../utils/collections/reports'; +import {formatPhoneNumber} from '../../utils/TestHelper'; import waitForBatchedUpdates from '../../utils/waitForBatchedUpdates'; jest.mock('@src/libs/Navigation/Navigation', () => ({ @@ -190,6 +191,7 @@ describe('buildOnyxDataForMoneyRequest', () => { optimisticParams: buildBaseOptimisticParams(IOU_REPORT_ID), delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }; } @@ -332,6 +334,7 @@ describe('buildOnyxDataForMoneyRequest', () => { optimisticParams: buildBaseOptimisticParams(IOU_REPORT_ID), delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }; } @@ -373,6 +376,7 @@ describe('buildOnyxDataForMoneyRequest', () => { optimisticParams: buildBaseOptimisticParams(IOU_REPORT_ID), delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }; } @@ -420,6 +424,7 @@ describe('buildOnyxDataForMoneyRequest', () => { }, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }; } @@ -475,4 +480,41 @@ describe('buildOnyxDataForMoneyRequest', () => { expect((chatReportEntry?.value as Partial)?.iouReportID).toBeUndefined(); }); }); + + it('uses the injected formatter for optimistic new-chat personal detail display name', () => { + const mockFormatPhoneNumber = jest.fn((phoneNumber: string) => `formatted:${phoneNumber}`); + const result = getMoneyRequestInformation({ + parentChatReport: undefined, + participantParams: { + payeeAccountID: CURRENT_USER_ACCOUNT_ID, + payeeEmail: CURRENT_USER_EMAIL, + participant: { + accountID: PAYER_ACCOUNT_ID, + login: '+15551234567', + }, + }, + transactionParams: { + amount: 1000, + currency: CONST.CURRENCY.USD, + created: '2024-01-01', + merchant: 'Test Merchant', + }, + betas: [], + isASAPSubmitBetaEnabled: false, + currentUserAccountIDParam: CURRENT_USER_ACCOUNT_ID, + currentUserEmailParam: CURRENT_USER_EMAIL, + transactionViolations: {}, + quickAction: undefined, + policyRecentlyUsedCurrencies: [], + personalDetails: {}, + delegateAccountID: undefined, + isTrackIntentUser: false, + formatPhoneNumber: mockFormatPhoneNumber, + }); + + const personalDetailsEntry = result.onyxData.optimisticData?.find((entry) => entry.key === ONYXKEYS.PERSONAL_DETAILS_LIST); + + expect(mockFormatPhoneNumber).toHaveBeenCalledWith('+15551234567'); + expect((personalDetailsEntry?.value as Record)?.[PAYER_ACCOUNT_ID]?.displayName).toBe('formatted:+15551234567'); + }); }); diff --git a/tests/actions/IOU/GetMoneyRequestInformationTest.ts b/tests/actions/IOU/GetMoneyRequestInformationTest.ts index dd76fa00547b..4b256c9f2d1f 100644 --- a/tests/actions/IOU/GetMoneyRequestInformationTest.ts +++ b/tests/actions/IOU/GetMoneyRequestInformationTest.ts @@ -6,6 +6,7 @@ import type {Beta, PolicyTagLists, Report} from '@src/types/onyx'; import Onyx from 'react-native-onyx'; +import {formatPhoneNumber} from '../../utils/TestHelper'; import waitForBatchedUpdates from '../../utils/waitForBatchedUpdates'; jest.mock('@src/libs/Navigation/Navigation', () => ({ @@ -70,6 +71,7 @@ const baseParams = { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, } as const; describe('getMoneyRequestInformation', () => { diff --git a/tests/actions/IOU/RequestMoneyTest.ts b/tests/actions/IOU/RequestMoneyTest.ts index 2c7a404ebe2e..865b202a8762 100644 --- a/tests/actions/IOU/RequestMoneyTest.ts +++ b/tests/actions/IOU/RequestMoneyTest.ts @@ -223,6 +223,7 @@ describe('actions/IOU', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); return waitForBatchedUpdates() .then( @@ -483,6 +484,7 @@ describe('actions/IOU', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); return waitForBatchedUpdates(); }) @@ -714,6 +716,7 @@ describe('actions/IOU', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); } return waitForBatchedUpdates(); @@ -880,6 +883,7 @@ describe('actions/IOU', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); return ( waitForBatchedUpdates() @@ -1398,6 +1402,7 @@ describe('actions/IOU', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); expect(notifyNewAction).toHaveBeenCalledTimes(0); }); @@ -1432,6 +1437,7 @@ describe('actions/IOU', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); expect(Navigation.setNavigationActionToMicrotaskQueue).toHaveBeenCalledTimes(1); }); @@ -1466,6 +1472,7 @@ describe('actions/IOU', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); // Verify that the iouReport is created successfully when isSelfTourViewed is true expect(iouReport).toBeDefined(); @@ -1519,6 +1526,7 @@ describe('actions/IOU', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -1565,6 +1573,7 @@ describe('actions/IOU', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -1638,6 +1647,7 @@ describe('actions/IOU', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); waitForBatchedUpdates(); @@ -1708,6 +1718,7 @@ describe('actions/IOU', () => { betas: [CONST.BETAS.ALL], delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); expect(iouReport).toBeDefined(); @@ -1783,6 +1794,7 @@ describe('actions/IOU', () => { betas: [CONST.BETAS.ALL], delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); expect(iouReport).toBeDefined(); @@ -1829,6 +1841,7 @@ describe('actions/IOU', () => { betas: [CONST.BETAS.ALL], delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); // Should still create the expense even with empty personalDetails @@ -1990,6 +2003,7 @@ describe('actions/IOU', () => { betas: [CONST.BETAS.ALL], delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -2066,6 +2080,7 @@ describe('actions/IOU', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); return waitForBatchedUpdates(); }) @@ -2154,6 +2169,7 @@ describe('actions/IOU', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); return waitForBatchedUpdates(); }) @@ -2233,6 +2249,7 @@ describe('actions/IOU', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); return waitForBatchedUpdates(); }) @@ -2307,6 +2324,7 @@ describe('actions/IOU', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); return waitForBatchedUpdates(); }) @@ -2382,6 +2400,7 @@ describe('actions/IOU', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); return waitForBatchedUpdates(); }) @@ -2454,6 +2473,7 @@ describe('actions/IOU', () => { personalDetails: {}, delegateAccountID: DELEGATE_ACCOUNT_ID, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -2535,6 +2555,7 @@ describe('actions/IOU', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -2594,6 +2615,7 @@ describe('actions/IOU', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -2665,6 +2687,7 @@ describe('actions/IOU', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -2792,6 +2815,7 @@ describe('actions/IOU', () => { optimisticChatReportID: undefined, currentUserLocalCurrency: 'USD', isTrackIntentUser: false, + formatPhoneNumber, delegateAccountID: undefined, }; }; diff --git a/tests/actions/IOU/SplitReportTotalsTest.ts b/tests/actions/IOU/SplitReportTotalsTest.ts index b6b37135863f..b1ea3093390d 100644 --- a/tests/actions/IOU/SplitReportTotalsTest.ts +++ b/tests/actions/IOU/SplitReportTotalsTest.ts @@ -774,6 +774,7 @@ describe('actions/IOU', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, ...overrides, }; } diff --git a/tests/actions/IOUTest/CreateExpenseByTypeTest.ts b/tests/actions/IOUTest/CreateExpenseByTypeTest.ts index 886870b35523..3d4712250e98 100644 --- a/tests/actions/IOUTest/CreateExpenseByTypeTest.ts +++ b/tests/actions/IOUTest/CreateExpenseByTypeTest.ts @@ -17,6 +17,7 @@ import Onyx from 'react-native-onyx'; import currencyList from '../../unit/currencyList.json'; import {createRandomReport} from '../../utils/collections/reports'; import createRandomTransaction from '../../utils/collections/transaction'; +import {formatPhoneNumber} from '../../utils/TestHelper'; import waitForBatchedUpdates from '../../utils/waitForBatchedUpdates'; jest.mock('@libs/actions/IOU/TrackExpense', () => ({ @@ -131,6 +132,7 @@ describe('actions/IOU/createExpenseByType', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: undefined, + formatPhoneNumber, }; return {transaction, transactionDetails, params}; diff --git a/tests/actions/IOUTest/DeleteMoneyRequestTest.ts b/tests/actions/IOUTest/DeleteMoneyRequestTest.ts index 483e20ef31a3..23f7f6700f7c 100644 --- a/tests/actions/IOUTest/DeleteMoneyRequestTest.ts +++ b/tests/actions/IOUTest/DeleteMoneyRequestTest.ts @@ -34,7 +34,7 @@ import {createRandomReport} from '../../utils/collections/reports'; import createRandomTransaction from '../../utils/collections/transaction'; import getOnyxValue from '../../utils/getOnyxValue'; import PusherHelper from '../../utils/PusherHelper'; -import {getGlobalFetchMock, getOnyxData, setPersonalDetails, signInWithTestUser} from '../../utils/TestHelper'; +import {formatPhoneNumber, getGlobalFetchMock, getOnyxData, setPersonalDetails, signInWithTestUser} from '../../utils/TestHelper'; import waitForBatchedUpdates from '../../utils/waitForBatchedUpdates'; const topMostReportID = '23423423'; @@ -194,6 +194,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -442,6 +443,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -1132,6 +1134,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); } @@ -1215,6 +1218,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -1386,6 +1390,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); } diff --git a/tests/actions/IOUTest/PayMoneyRequestTest.ts b/tests/actions/IOUTest/PayMoneyRequestTest.ts index 30da09e378eb..76cdcb7d8a14 100644 --- a/tests/actions/IOUTest/PayMoneyRequestTest.ts +++ b/tests/actions/IOUTest/PayMoneyRequestTest.ts @@ -35,7 +35,7 @@ import createRandomReportAction from '../../utils/collections/reportActions'; import {createRandomReport} from '../../utils/collections/reports'; import createRandomTransaction from '../../utils/collections/transaction'; import getOnyxValue from '../../utils/getOnyxValue'; -import {getGlobalFetchMock, getOnyxData, translateLocal} from '../../utils/TestHelper'; +import {formatPhoneNumber, getGlobalFetchMock, getOnyxData, translateLocal} from '../../utils/TestHelper'; import waitForBatchedUpdates from '../../utils/waitForBatchedUpdates'; const topMostReportID = '23423423'; @@ -166,6 +166,7 @@ describe('actions/IOU/PayMoneyRequest', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); return waitForBatchedUpdates() .then( @@ -434,6 +435,7 @@ describe('actions/IOU/PayMoneyRequest', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); } return waitForBatchedUpdates(); @@ -601,6 +603,7 @@ describe('actions/IOU/PayMoneyRequest', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); } return waitForBatchedUpdates(); @@ -1491,6 +1494,7 @@ describe('actions/IOU/PayMoneyRequest', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); } return waitForBatchedUpdates(); @@ -1619,6 +1623,7 @@ describe('actions/IOU/PayMoneyRequest', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); } await waitForBatchedUpdates(); @@ -1870,6 +1875,7 @@ describe('actions/IOU/PayMoneyRequest', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); } await waitForBatchedUpdates(); diff --git a/tests/actions/IOUTest/ReportWorkflowTest.ts b/tests/actions/IOUTest/ReportWorkflowTest.ts index f26d892da465..45a198d9960d 100644 --- a/tests/actions/IOUTest/ReportWorkflowTest.ts +++ b/tests/actions/IOUTest/ReportWorkflowTest.ts @@ -227,6 +227,7 @@ describe('actions/IOU/ReportWorkflow', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); } return waitForBatchedUpdates(); @@ -377,6 +378,7 @@ describe('actions/IOU/ReportWorkflow', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); } return waitForBatchedUpdates(); @@ -459,6 +461,7 @@ describe('actions/IOU/ReportWorkflow', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); } return waitForBatchedUpdates(); @@ -507,6 +510,7 @@ describe('actions/IOU/ReportWorkflow', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); } return waitForBatchedUpdates(); @@ -733,6 +737,7 @@ describe('actions/IOU/ReportWorkflow', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); } return waitForBatchedUpdates(); @@ -781,6 +786,7 @@ describe('actions/IOU/ReportWorkflow', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); } return waitForBatchedUpdates(); @@ -976,6 +982,7 @@ describe('actions/IOU/ReportWorkflow', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); } return waitForBatchedUpdates(); @@ -1184,6 +1191,7 @@ describe('actions/IOU/ReportWorkflow', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); } await waitForBatchedUpdates(); diff --git a/tests/actions/IOUTest/SplitSelfDMTest.ts b/tests/actions/IOUTest/SplitSelfDMTest.ts index d881a570d7bc..2130ba86b7d9 100644 --- a/tests/actions/IOUTest/SplitSelfDMTest.ts +++ b/tests/actions/IOUTest/SplitSelfDMTest.ts @@ -20,7 +20,7 @@ import type {MockFetch} from '../../utils/TestHelper'; import createPersonalDetails from '../../utils/collections/personalDetails'; import {createSelfDM} from '../../utils/collections/reports'; import getOnyxValue from '../../utils/getOnyxValue'; -import {getGlobalFetchMock, getOnyxData} from '../../utils/TestHelper'; +import {formatPhoneNumber, getGlobalFetchMock, getOnyxData} from '../../utils/TestHelper'; import waitForBatchedUpdates from '../../utils/waitForBatchedUpdates'; import waitForNetworkPromises from '../../utils/waitForNetworkPromises'; @@ -218,6 +218,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow - selfDM', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -305,6 +306,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow - selfDM', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -412,6 +414,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow - selfDM', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -505,6 +508,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow - selfDM', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -566,6 +570,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow - selfDM', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -656,6 +661,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow - selfDM', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); diff --git a/tests/actions/IOUTest/SplitTest.ts b/tests/actions/IOUTest/SplitTest.ts index 7e8e434393de..5e238603b33b 100644 --- a/tests/actions/IOUTest/SplitTest.ts +++ b/tests/actions/IOUTest/SplitTest.ts @@ -1349,6 +1349,7 @@ describe('split expense', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -1879,6 +1880,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -1999,6 +2001,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -2131,6 +2134,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -2211,6 +2215,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -2297,6 +2302,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -2358,6 +2364,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -2438,6 +2445,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -2553,6 +2561,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -2616,6 +2625,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -2681,6 +2691,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -2754,6 +2765,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -2905,6 +2917,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -3047,6 +3060,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -3158,6 +3172,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -3291,6 +3306,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -3423,6 +3439,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -3544,6 +3561,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); } @@ -3685,6 +3703,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -3771,6 +3790,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -3877,6 +3897,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -4052,6 +4073,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -4187,6 +4209,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -4264,6 +4287,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); await getOnyxData({ @@ -4372,6 +4396,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -4442,6 +4467,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); await getOnyxData({ @@ -4550,6 +4576,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -4625,6 +4652,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -4742,6 +4770,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -4818,6 +4847,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -4956,6 +4986,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -5074,6 +5105,7 @@ describe('updateSplitTransactions', () => { existingTransactionDraft: undefined, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -5142,6 +5174,7 @@ describe('updateSplitTransactions', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -5210,6 +5243,7 @@ describe('updateSplitTransactions', () => { draftTransactionIDs: [], delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -5278,6 +5312,7 @@ describe('updateSplitTransactions', () => { isOffline: true, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -5346,6 +5381,7 @@ describe('updateSplitTransactions', () => { existingTransactionDraft: undefined, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -5412,6 +5448,7 @@ describe('updateSplitTransactions', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -5493,6 +5530,7 @@ describe('updateSplitTransactions', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -5593,6 +5631,7 @@ describe('updateSplitTransactions', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -5660,6 +5699,7 @@ describe('updateSplitTransactions', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); const updateSplitTransactionCall = writeSpy.mock.calls.find(([command]) => command === WRITE_COMMANDS.UPDATE_SPLIT_TRANSACTION); @@ -5921,6 +5961,7 @@ describe('updateSplitTransactions', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -6035,6 +6076,7 @@ describe('updateSplitTransactions', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -6113,6 +6155,7 @@ describe('updateSplitTransactions', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -6184,6 +6227,7 @@ describe('updateSplitTransactions', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -6260,6 +6304,7 @@ describe('updateSplitTransactions', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -6331,6 +6376,7 @@ describe('updateSplitTransactions', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -6443,6 +6489,7 @@ describe('updateSplitTransactions', () => { isOffline: true, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); diff --git a/tests/actions/IOUTest/TrackExpenseTest.ts b/tests/actions/IOUTest/TrackExpenseTest.ts index 6836b903a7c9..25f603e4f120 100644 --- a/tests/actions/IOUTest/TrackExpenseTest.ts +++ b/tests/actions/IOUTest/TrackExpenseTest.ts @@ -2826,6 +2826,7 @@ describe('actions/IOU/TrackExpense', () => { selfDMReportActions: undefined, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); }).not.toThrow(); }); @@ -2900,6 +2901,7 @@ describe('actions/IOU/TrackExpense', () => { selfDMReportActions: undefined, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); }).not.toThrow(); }); @@ -2944,6 +2946,7 @@ describe('actions/IOU/TrackExpense', () => { selfDMReportActions: undefined, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); }).not.toThrow(); }); @@ -2988,6 +2991,7 @@ describe('actions/IOU/TrackExpense', () => { selfDMReportActions: undefined, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); }).not.toThrow(); }); diff --git a/tests/actions/TransactionTest.ts b/tests/actions/TransactionTest.ts index 403b241fbce3..e2b0e999da7b 100644 --- a/tests/actions/TransactionTest.ts +++ b/tests/actions/TransactionTest.ts @@ -36,7 +36,7 @@ import createPersonalDetails from '../utils/collections/personalDetails'; import createRandomPolicy from '../utils/collections/policies'; import {createRandomReport} from '../utils/collections/reports'; import getOnyxValue from '../utils/getOnyxValue'; -import {getGlobalFetchMock, getOnyxData} from '../utils/TestHelper'; +import {formatPhoneNumber, getGlobalFetchMock, getOnyxData} from '../utils/TestHelper'; import waitForBatchedUpdates from '../utils/waitForBatchedUpdates'; type LegacyChangeTransactionsReportProps = Omit< @@ -622,6 +622,7 @@ describe('actions/Transaction', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); await getOnyxData({ @@ -729,6 +730,7 @@ describe('actions/Transaction', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -800,6 +802,7 @@ describe('actions/Transaction', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); await getOnyxData({ @@ -907,6 +910,7 @@ describe('actions/Transaction', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -983,6 +987,7 @@ describe('actions/Transaction', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -1099,6 +1104,7 @@ describe('actions/Transaction', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -1176,6 +1182,7 @@ describe('actions/Transaction', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -1313,6 +1320,7 @@ describe('actions/Transaction', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); diff --git a/tests/unit/IOUAmountSubmissionTest.ts b/tests/unit/IOUAmountSubmissionTest.ts index 93553d7530b5..2998137d629c 100644 --- a/tests/unit/IOUAmountSubmissionTest.ts +++ b/tests/unit/IOUAmountSubmissionTest.ts @@ -12,7 +12,7 @@ import Onyx from 'react-native-onyx'; import createRandomPolicy from '../utils/collections/policies'; import {createRandomReport} from '../utils/collections/reports'; -import {translateLocal} from '../utils/TestHelper'; +import {formatPhoneNumber, translateLocal} from '../utils/TestHelper'; import waitForBatchedUpdates from '../utils/waitForBatchedUpdates'; const CURRENT_USER_ACCOUNT_ID = 5; @@ -195,6 +195,7 @@ describe('AmountSubmission', () => { navigateBack: jest.fn(), amount: '10', paymentMethod: undefined, + formatPhoneNumber, allPersonalDetails: {}, allReports: {}, allReportDrafts: {}, From 5dac56d51b4a0534d01490fd212670226af1a7e9 Mon Sep 17 00:00:00 2001 From: Maruf Sharifi Date: Mon, 3 Aug 2026 16:33:11 +0430 Subject: [PATCH 2/6] fixed lint failure --- src/libs/actions/IOU/MoneyRequestBuilder.ts | 3 --- tests/actions/IOU/BuildOnyxDataForMoneyRequestTest.ts | 4 ---- 2 files changed, 7 deletions(-) diff --git a/src/libs/actions/IOU/MoneyRequestBuilder.ts b/src/libs/actions/IOU/MoneyRequestBuilder.ts index 0776938f2f1e..ca09735a3cab 100644 --- a/src/libs/actions/IOU/MoneyRequestBuilder.ts +++ b/src/libs/actions/IOU/MoneyRequestBuilder.ts @@ -282,7 +282,6 @@ type BuildOnyxDataForMoneyRequestParams = { /** The selfDM report ID for split transactions */ selfDMReportID?: string; isTrackIntentUser: boolean | undefined; - formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; }; type BuildOnyxDataForTestDriveIOUParams = { @@ -445,7 +444,6 @@ function buildOnyxDataForMoneyRequest(moneyRequestParams: BuildOnyxDataForMoneyR isReverseSplitOperation, selfDMReportID, isTrackIntentUser, - formatPhoneNumber, } = moneyRequestParams; const {policy, policyCategories, policyTagList} = policyParams; const { @@ -1707,7 +1705,6 @@ function getMoneyRequestInformation(moneyRequestInformation: MoneyRequestInforma isSelfDMSplit, selfDMReportID, isTrackIntentUser, - formatPhoneNumber, }); return { diff --git a/tests/actions/IOU/BuildOnyxDataForMoneyRequestTest.ts b/tests/actions/IOU/BuildOnyxDataForMoneyRequestTest.ts index 2d53ea6ce6d1..9d0ddca39baa 100644 --- a/tests/actions/IOU/BuildOnyxDataForMoneyRequestTest.ts +++ b/tests/actions/IOU/BuildOnyxDataForMoneyRequestTest.ts @@ -191,7 +191,6 @@ describe('buildOnyxDataForMoneyRequest', () => { optimisticParams: buildBaseOptimisticParams(IOU_REPORT_ID), delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber, }; } @@ -334,7 +333,6 @@ describe('buildOnyxDataForMoneyRequest', () => { optimisticParams: buildBaseOptimisticParams(IOU_REPORT_ID), delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber, }; } @@ -376,7 +374,6 @@ describe('buildOnyxDataForMoneyRequest', () => { optimisticParams: buildBaseOptimisticParams(IOU_REPORT_ID), delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber, }; } @@ -424,7 +421,6 @@ describe('buildOnyxDataForMoneyRequest', () => { }, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber, }; } From 1bcabe4443c22128be12bfbe9fe9b4f17ac5c0eb Mon Sep 17 00:00:00 2001 From: Maruf Sharifi Date: Mon, 3 Aug 2026 17:01:26 +0430 Subject: [PATCH 3/6] fixed type failures --- src/libs/actions/IOU/PerDiem.ts | 1 - src/libs/actions/IOU/Split.ts | 2 -- 2 files changed, 3 deletions(-) diff --git a/src/libs/actions/IOU/PerDiem.ts b/src/libs/actions/IOU/PerDiem.ts index ea1432a0a4e6..5785948aabda 100644 --- a/src/libs/actions/IOU/PerDiem.ts +++ b/src/libs/actions/IOU/PerDiem.ts @@ -578,7 +578,6 @@ function getPerDiemExpenseInformation(perDiemExpenseInformation: PerDiemExpenseI personalDetails, delegateAccountID, isTrackIntentUser, - formatPhoneNumber, }); return { diff --git a/src/libs/actions/IOU/Split.ts b/src/libs/actions/IOU/Split.ts index 67c30d3aec1d..d48dabafcd27 100644 --- a/src/libs/actions/IOU/Split.ts +++ b/src/libs/actions/IOU/Split.ts @@ -1160,7 +1160,6 @@ function completeSplitBill({ personalDetails, delegateAccountID, isTrackIntentUser, - formatPhoneNumber, }); splits.push({ @@ -1901,7 +1900,6 @@ function createSplitsAndOnyxData({ personalDetails, delegateAccountID, isTrackIntentUser, - formatPhoneNumber, }); const individualSplit = { From 3dab925dc87910b2ed9a81793ba2fbe2388f358c Mon Sep 17 00:00:00 2001 From: Maruf Sharifi Date: Mon, 3 Aug 2026 17:53:20 +0430 Subject: [PATCH 4/6] fixed type & lint errors --- src/libs/actions/IOU/Split.ts | 2 -- src/pages/iou/DynamicSplitBillDetailsPage.tsx | 4 +--- tests/actions/IOU/BuildOnyxDataForMoneyRequestTest.ts | 1 - tests/actions/IOUTest/SplitTest.ts | 2 -- 4 files changed, 1 insertion(+), 8 deletions(-) diff --git a/src/libs/actions/IOU/Split.ts b/src/libs/actions/IOU/Split.ts index d48dabafcd27..9048f3107b47 100644 --- a/src/libs/actions/IOU/Split.ts +++ b/src/libs/actions/IOU/Split.ts @@ -218,7 +218,6 @@ type CompleteSplitBillActionParams = { delegateAccountID: number | undefined; isTrackIntentUser: boolean | undefined; sessionEmail?: string; - formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; }; type SplitBillActionsParams = { @@ -911,7 +910,6 @@ function completeSplitBill({ delegateAccountID, isTrackIntentUser, sessionEmail, - formatPhoneNumber, }: CompleteSplitBillActionParams) { if (!reportAction) { return; diff --git a/src/pages/iou/DynamicSplitBillDetailsPage.tsx b/src/pages/iou/DynamicSplitBillDetailsPage.tsx index ac9abe51d85a..df58cfea9391 100644 --- a/src/pages/iou/DynamicSplitBillDetailsPage.tsx +++ b/src/pages/iou/DynamicSplitBillDetailsPage.tsx @@ -48,7 +48,7 @@ type SplitBillDetailsPageProps = WithReportAndReportActionOrNotFoundProps & Plat function DynamicSplitBillDetailsPage({report, reportAction}: SplitBillDetailsPageProps) { const styles = useThemeStyles(); - const {translate, formatPhoneNumber} = useLocalize(); + const {translate} = useLocalize(); const theme = useTheme(); const {isBetaEnabled} = usePermissions(); const icons = useMemoizedLazyExpensifyIcons(['ReceiptScan']); @@ -119,7 +119,6 @@ function DynamicSplitBillDetailsPage({report, reportAction}: SplitBillDetailsPag delegateAccountID, isTrackIntentUser, sessionEmail: session?.email, - formatPhoneNumber, }); }, [ reportID, @@ -134,7 +133,6 @@ function DynamicSplitBillDetailsPage({report, reportAction}: SplitBillDetailsPag personalDetails, delegateAccountID, isTrackIntentUser, - formatPhoneNumber, ]); return ( diff --git a/tests/actions/IOU/BuildOnyxDataForMoneyRequestTest.ts b/tests/actions/IOU/BuildOnyxDataForMoneyRequestTest.ts index 9d0ddca39baa..d6927f9c88fc 100644 --- a/tests/actions/IOU/BuildOnyxDataForMoneyRequestTest.ts +++ b/tests/actions/IOU/BuildOnyxDataForMoneyRequestTest.ts @@ -9,7 +9,6 @@ import type {Report, ReportAction, Transaction} from '@src/types/onyx'; import Onyx from 'react-native-onyx'; import {createSelfDM} from '../../utils/collections/reports'; -import {formatPhoneNumber} from '../../utils/TestHelper'; import waitForBatchedUpdates from '../../utils/waitForBatchedUpdates'; jest.mock('@src/libs/Navigation/Navigation', () => ({ diff --git a/tests/actions/IOUTest/SplitTest.ts b/tests/actions/IOUTest/SplitTest.ts index 5e238603b33b..1e31c18ab7f5 100644 --- a/tests/actions/IOUTest/SplitTest.ts +++ b/tests/actions/IOUTest/SplitTest.ts @@ -1207,7 +1207,6 @@ describe('split expense', () => { delegateAccountID: undefined, isTrackIntentUser: false, sessionEmail: RORY_EMAIL, - formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -1622,7 +1621,6 @@ describe('split expense', () => { delegateAccountID: undefined, isTrackIntentUser: false, sessionEmail: RORY_EMAIL, - formatPhoneNumber, }); await waitForBatchedUpdates(); From 0a61fb7b936b64ed68c5fad85b5309e3e0fe70c3 Mon Sep 17 00:00:00 2001 From: Maruf Sharifi Date: Mon, 3 Aug 2026 19:49:17 +0430 Subject: [PATCH 5/6] fixed type failures --- tests/actions/IOU/RequestMoneyTest.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/actions/IOU/RequestMoneyTest.ts b/tests/actions/IOU/RequestMoneyTest.ts index a4ff80282512..2b44da9a4b34 100644 --- a/tests/actions/IOU/RequestMoneyTest.ts +++ b/tests/actions/IOU/RequestMoneyTest.ts @@ -2557,6 +2557,7 @@ describe('actions/IOU', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); From f729e8ee27204e165117cd786adf7a148769b429 Mon Sep 17 00:00:00 2001 From: Maruf Sharifi Date: Mon, 3 Aug 2026 20:29:15 +0430 Subject: [PATCH 6/6] Pass phone formatter into split bill completion --- src/libs/actions/IOU/Split.ts | 1 + src/pages/iou/DynamicSplitBillDetailsPage.tsx | 4 +++- tests/actions/IOUTest/SplitTest.ts | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/IOU/Split.ts b/src/libs/actions/IOU/Split.ts index 423e393396c7..7bfcbaa49068 100644 --- a/src/libs/actions/IOU/Split.ts +++ b/src/libs/actions/IOU/Split.ts @@ -221,6 +221,7 @@ type CompleteSplitBillActionParams = { delegateAccountID: number | undefined; isTrackIntentUser: boolean | undefined; sessionEmail?: string; + formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; }; type SplitBillActionsParams = { diff --git a/src/pages/iou/DynamicSplitBillDetailsPage.tsx b/src/pages/iou/DynamicSplitBillDetailsPage.tsx index df58cfea9391..ac9abe51d85a 100644 --- a/src/pages/iou/DynamicSplitBillDetailsPage.tsx +++ b/src/pages/iou/DynamicSplitBillDetailsPage.tsx @@ -48,7 +48,7 @@ type SplitBillDetailsPageProps = WithReportAndReportActionOrNotFoundProps & Plat function DynamicSplitBillDetailsPage({report, reportAction}: SplitBillDetailsPageProps) { const styles = useThemeStyles(); - const {translate} = useLocalize(); + const {translate, formatPhoneNumber} = useLocalize(); const theme = useTheme(); const {isBetaEnabled} = usePermissions(); const icons = useMemoizedLazyExpensifyIcons(['ReceiptScan']); @@ -119,6 +119,7 @@ function DynamicSplitBillDetailsPage({report, reportAction}: SplitBillDetailsPag delegateAccountID, isTrackIntentUser, sessionEmail: session?.email, + formatPhoneNumber, }); }, [ reportID, @@ -133,6 +134,7 @@ function DynamicSplitBillDetailsPage({report, reportAction}: SplitBillDetailsPag personalDetails, delegateAccountID, isTrackIntentUser, + formatPhoneNumber, ]); return ( diff --git a/tests/actions/IOUTest/SplitTest.ts b/tests/actions/IOUTest/SplitTest.ts index 9fda8d0863a0..0cb2d8b323e3 100644 --- a/tests/actions/IOUTest/SplitTest.ts +++ b/tests/actions/IOUTest/SplitTest.ts @@ -1208,6 +1208,7 @@ describe('split expense', () => { delegateAccountID: undefined, isTrackIntentUser: false, sessionEmail: RORY_EMAIL, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -1622,6 +1623,7 @@ describe('split expense', () => { delegateAccountID: undefined, isTrackIntentUser: false, sessionEmail: RORY_EMAIL, + formatPhoneNumber, }); await waitForBatchedUpdates();