From 8420afaeb3a0e16a55f52bef17acf593869f6964 Mon Sep 17 00:00:00 2001 From: Maruf Sharifi Date: Wed, 15 Jul 2026 18:10:32 +0300 Subject: [PATCH 01/12] Remove Onyx.connect from LocalePhoneNumber for IOU actions, Task, and pages --- src/hooks/useDeleteTransactions.ts | 4 ++++ src/libs/actions/IOU/MoneyRequestBuilder.ts | 5 ++++- src/libs/actions/IOU/PerDiem.ts | 8 +++++++- src/libs/actions/IOU/SendInvoice.ts | 7 ++++++- src/libs/actions/IOU/Split.ts | 16 +++++++++++++++- src/libs/actions/IOU/SplitTransactionUpdate.ts | 4 ++++ src/libs/actions/Task.ts | 17 +++++++++++------ src/pages/Travel/TravelLegalNamePage.tsx | 3 +-- .../request/step/IOURequestStepCompanyInfo.tsx | 3 ++- .../components/ScanSkipConfirmation.tsx | 3 ++- .../step/confirmation/useExpenseSubmission.ts | 7 ++++++- src/pages/tasks/DynamicNewTaskPage.tsx | 6 ++++-- 12 files changed, 66 insertions(+), 17 deletions(-) diff --git a/src/hooks/useDeleteTransactions.ts b/src/hooks/useDeleteTransactions.ts index a4ce13942489..0eeb3cdab076 100644 --- a/src/hooks/useDeleteTransactions.ts +++ b/src/hooks/useDeleteTransactions.ts @@ -1,5 +1,7 @@ import {useSearchQueryContext, useSearchResultsContext} from '@components/Search/SearchContext'; +import useLocalize from '@hooks/useLocalize'; + import {deleteMoneyRequest} from '@libs/actions/IOU/DeleteMoneyRequest'; import {getIOUActionForTransactions} from '@libs/actions/IOU/Duplicate'; import {getIOURequestPolicyID} from '@libs/actions/IOU/MoneyRequest'; @@ -71,6 +73,7 @@ function redistributeRemainingPerDiemSplitExpenses(splitExpenses: SplitExpense[] * All data must be provided through function parameters */ function useDeleteTransactions({report, reportActions, policy}: UseDeleteTransactionsParams) { + const {formatPhoneNumber} = useLocalize(); const {currentSearchResults} = useSearchResultsContext(); const {currentSearchQueryJSON} = useSearchQueryContext(); const [allTransactions] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION); @@ -323,6 +326,7 @@ function useDeleteTransactions({report, reportActions, policy}: UseDeleteTransac expenseReport, isOffline, isTrackIntentUser, + formatPhoneNumber, }); } diff --git a/src/libs/actions/IOU/MoneyRequestBuilder.ts b/src/libs/actions/IOU/MoneyRequestBuilder.ts index cb0d841ee694..6af32867d783 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'; @@ -225,6 +226,7 @@ type MoneyRequestInformationParams = { personalDetails: OnyxEntry; isTrackIntentUser: boolean | undefined; delegateAccountID: number | undefined; + formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; }; type MoneyRequestOptimisticParams = { @@ -1291,6 +1293,7 @@ function getMoneyRequestInformation(moneyRequestInformation: MoneyRequestInforma betas, delegateAccountID, isTrackIntentUser, + formatPhoneNumber, } = moneyRequestInformation; const {payeeAccountID = currentUserAccountIDParam, payeeEmail = currentUserEmailParam, participant} = participantParams; const {policy, policyCategories, policyTagList, policyRecentlyUsedCategories, policyRecentlyUsedTags} = policyParams; diff --git a/src/libs/actions/IOU/PerDiem.ts b/src/libs/actions/IOU/PerDiem.ts index 9292a1f7c02b..fd3c915cd979 100644 --- a/src/libs/actions/IOU/PerDiem.ts +++ b/src/libs/actions/IOU/PerDiem.ts @@ -1,3 +1,5 @@ +import type {LocaleContextProps} from '@components/LocaleContextProvider'; + import * as API from '@libs/API'; import type {CreatePerDiemRequestParams} from '@libs/API/parameters'; import {WRITE_COMMANDS} from '@libs/API/types'; @@ -6,7 +8,6 @@ import DateUtils from '@libs/DateUtils'; import {deferOrExecuteWrite} from '@libs/deferredLayoutWrite'; import {getMicroSecondOnyxErrorWithTranslationKey} from '@libs/ErrorUtils'; import {updateIOUOwnerAndTotal} from '@libs/IOUUtils'; -import {formatPhoneNumber} from '@libs/LocalePhoneNumber'; import {validateAmount} from '@libs/MoneyRequestUtils'; import Navigation from '@libs/Navigation/Navigation'; import TransitionTracker from '@libs/Navigation/TransitionTracker'; @@ -243,6 +244,7 @@ type PerDiemExpenseInformation = { // TODO: delegateAccountID will be made required in PR 13 when all callers pass the value (https://github.com/Expensify/App/issues/66425) delegateAccountID?: number | undefined; isTrackIntentUser: boolean | undefined; + formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; }; type PerDiemExpenseInformationParams = { @@ -267,6 +269,7 @@ type PerDiemExpenseInformationParams = { // TODO: delegateAccountID will be made required in PR 13 when all callers pass the value (https://github.com/Expensify/App/issues/66425) delegateAccountID?: number | undefined; isTrackIntentUser: boolean | undefined; + formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; }; type PerDiemExpenseInformationForSelfDM = { @@ -324,6 +327,7 @@ function getPerDiemExpenseInformation(perDiemExpenseInformation: PerDiemExpenseI optimisticTransactionID: uiProvidedOptimisticTransactionID, delegateAccountID, isTrackIntentUser, + formatPhoneNumber, } = perDiemExpenseInformation; const {payeeAccountID = currentUserAccountIDParam, payeeEmail = currentUserEmailParam, participant} = participantParams; const {policy, policyCategories, policyTagList, policyRecentlyUsedCategories, policyRecentlyUsedTags} = policyParams; @@ -932,6 +936,7 @@ function submitPerDiemExpense(submitPerDiemExpenseInformation: PerDiemExpenseInf optimisticTransactionID, delegateAccountID, isTrackIntentUser, + formatPhoneNumber, } = submitPerDiemExpenseInformation; const {currency, comment = '', category, tag, created, customUnit, attendees, isFromGlobalCreate} = transactionParams; @@ -985,6 +990,7 @@ function submitPerDiemExpense(submitPerDiemExpenseInformation: PerDiemExpenseInf optimisticTransactionID, delegateAccountID, isTrackIntentUser, + formatPhoneNumber, }); const activeReportID = isMoneyRequestReport && Navigation.getTopmostReportId() === report?.reportID ? report?.reportID : chatReport.reportID; diff --git a/src/libs/actions/IOU/SendInvoice.ts b/src/libs/actions/IOU/SendInvoice.ts index b78e32a89051..e66e34d48499 100644 --- a/src/libs/actions/IOU/SendInvoice.ts +++ b/src/libs/actions/IOU/SendInvoice.ts @@ -1,10 +1,11 @@ +import type {LocaleContextProps} from '@components/LocaleContextProvider'; + import * as API from '@libs/API'; import type {SendInvoiceParams} from '@libs/API/parameters'; import {WRITE_COMMANDS} from '@libs/API/types'; import DateUtils from '@libs/DateUtils'; import {deferOrExecuteWrite} from '@libs/deferredLayoutWrite'; import {getMicroSecondOnyxErrorWithTranslationKey} from '@libs/ErrorUtils'; -import {formatPhoneNumber} from '@libs/LocalePhoneNumber'; import Log from '@libs/Log'; import {getReportActionHtml, getReportActionText} from '@libs/ReportActionsUtils'; import type {OptimisticChatReport, OptimisticCreatedReportAction, OptimisticIOUReportAction} from '@libs/ReportUtils'; @@ -87,6 +88,7 @@ type SendInvoiceOptions = { senderPolicyTags: OnyxEntry; // TODO: delegateAccountID will be made required in PR 12 when all callers pass the value (https://github.com/Expensify/App/issues/66425) delegateAccountID?: number | undefined; + formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; }; type BuildOnyxDataForInvoiceParams = { @@ -591,6 +593,7 @@ function getSendInvoiceInformation({ policyRecentlyUsedTags, senderPolicyTags, delegateAccountID, + formatPhoneNumber, }: SendInvoiceOptions): SendInvoiceInformation { const {amount = 0, currency = '', created = '', merchant = '', category = '', tag = '', taxCode = '', taxAmount = 0, taxValue, billable, comment, participants} = transaction ?? {}; const trimmedComment = (comment?.comment ?? '').trim(); @@ -740,6 +743,7 @@ function sendInvoice({ isFromGlobalCreate = false, senderPolicyTags, delegateAccountID, + formatPhoneNumber, }: SendInvoiceOptions) { const parsedComment = getParsedComment(transaction?.comment?.comment?.trim() ?? ''); if (transaction?.comment) { @@ -775,6 +779,7 @@ function sendInvoice({ policyRecentlyUsedTags, senderPolicyTags: senderPolicyTags ?? {}, delegateAccountID, + formatPhoneNumber, }); const parameters: SendInvoiceParams = { diff --git a/src/libs/actions/IOU/Split.ts b/src/libs/actions/IOU/Split.ts index 697fa680bbc9..671c403543e1 100644 --- a/src/libs/actions/IOU/Split.ts +++ b/src/libs/actions/IOU/Split.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 {CompleteSplitBillParams, CreateDistanceRequestParams, SplitBillParams, StartSplitBillParams} from '@libs/API/parameters'; import {WRITE_COMMANDS} from '@libs/API/types'; @@ -7,7 +9,6 @@ import DateUtils from '@libs/DateUtils'; import {deferOrExecuteWrite} from '@libs/deferredLayoutWrite'; import {getMicroSecondOnyxErrorWithTranslationKey} from '@libs/ErrorUtils'; import {calculateAmount as calculateIOUAmount, updateIOUOwnerAndTotal} from '@libs/IOUUtils'; -import {formatPhoneNumber} from '@libs/LocalePhoneNumber'; import * as Localize from '@libs/Localize'; import Navigation from '@libs/Navigation/Navigation'; import TransitionTracker from '@libs/Navigation/TransitionTracker'; @@ -143,6 +144,7 @@ type CreateDistanceRequestInformation = { previousOdometerDraft?: OnyxEntry; delegateAccountID: number | undefined; isTrackIntentUser: boolean | undefined; + formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; }; type CreateSplitsTransactionParams = Omit & { @@ -169,6 +171,7 @@ type CreateSplitsAndOnyxDataParams = { // TODO: delegateAccountID will be made required in PR 11 when all callers pass the value (https://github.com/Expensify/App/issues/66425) delegateAccountID?: number | undefined; isTrackIntentUser: boolean | undefined; + formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; }; type StartSplitBilActionParams = { @@ -194,6 +197,7 @@ type StartSplitBilActionParams = { quickAction: OnyxEntry; policyRecentlyUsedCurrencies: string[]; participantsPolicyTags: Record; + formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; }; type SplitBillActionsParams = { @@ -229,6 +233,7 @@ type SplitBillActionsParams = { // TODO: delegateAccountID will be made required in PR 11 when all callers pass the value (https://github.com/Expensify/App/issues/66425) delegateAccountID?: number | undefined; isTrackIntentUser: boolean | undefined; + formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; }; type CompleteSplitBillInformation = { @@ -280,6 +285,7 @@ function splitBill({ shouldDeferForSearch = false, delegateAccountID, isTrackIntentUser, + formatPhoneNumber, }: SplitBillActionsParams) { const parsedComment = getParsedComment(comment); const {splitData, splits, onyxData} = createSplitsAndOnyxData({ @@ -315,6 +321,7 @@ function splitBill({ participantsPolicyTags: buildParticipantsPolicyTags(participants), delegateAccountID, isTrackIntentUser, + formatPhoneNumber, }); const parameters: SplitBillParams = { @@ -394,6 +401,7 @@ function splitBillAndOpenReport({ shouldDeferForSearch = false, delegateAccountID, isTrackIntentUser, + formatPhoneNumber, }: SplitBillActionsParams) { const parsedComment = getParsedComment(comment); const {splitData, splits, onyxData} = createSplitsAndOnyxData({ @@ -429,6 +437,7 @@ function splitBillAndOpenReport({ participantsPolicyTags: buildParticipantsPolicyTags(participants), delegateAccountID, isTrackIntentUser, + formatPhoneNumber, }); const parameters: SplitBillParams = { @@ -501,6 +510,7 @@ function startSplitBill({ participantsPolicyTags, shouldHandleNavigation = true, shouldDeferForSearch = false, + formatPhoneNumber, }: StartSplitBilActionParams) { const currentUserEmailForIOUSplit = addSMSDomainIfPhoneNumber(currentUserLogin); const participantAccountIDs = participants.map((participant) => Number(participant.accountID)); @@ -1425,6 +1435,7 @@ function createSplitsAndOnyxData({ participantsPolicyTags, delegateAccountID, isTrackIntentUser, + formatPhoneNumber, }: CreateSplitsAndOnyxDataParams): SplitsAndOnyxData { const currentUserEmailForIOUSplit = addSMSDomainIfPhoneNumber(currentUserLogin); const participantAccountIDs = participants.map((participant) => Number(participant.accountID)); @@ -1959,6 +1970,7 @@ function createDistanceRequest(distanceRequestInformation: CreateDistanceRequest previousOdometerDraft, delegateAccountID, isTrackIntentUser, + formatPhoneNumber, } = distanceRequestInformation; const {policy, policyCategories, policyTagList, policyRecentlyUsedCategories, policyRecentlyUsedTags} = policyParams; const parsedComment = getParsedComment(transactionParams.comment); @@ -2051,6 +2063,7 @@ function createDistanceRequest(distanceRequestInformation: CreateDistanceRequest participantsPolicyTags: buildParticipantsPolicyTags(participants), delegateAccountID, isTrackIntentUser, + formatPhoneNumber, }); onyxData = splitOnyxData; @@ -2144,6 +2157,7 @@ function createDistanceRequest(distanceRequestInformation: CreateDistanceRequest optimisticReportPreviewActionID, delegateAccountID, isTrackIntentUser, + formatPhoneNumber, }); onyxData = moneyRequestOnyxData; diff --git a/src/libs/actions/IOU/SplitTransactionUpdate.ts b/src/libs/actions/IOU/SplitTransactionUpdate.ts index 5719edf8aa64..305f0dea3746 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'; @@ -108,6 +109,7 @@ type UpdateSplitTransactionsParams = { expenseReport: OnyxEntry; isOffline: boolean; isTrackIntentUser: boolean | undefined; + formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; }; function updateSplitTransactions({ @@ -137,6 +139,7 @@ function updateSplitTransactions({ expenseReport: expenseReportFromParams, isOffline, isTrackIntentUser, + formatPhoneNumber, }: UpdateSplitTransactionsParams) { const parentTransactionReport = getReportOrDraftReport(transactionReport?.parentReportID); // For selfDM-origin splits the caller can't resolve a real `expenseReport` (the draft/source @@ -710,6 +713,7 @@ function updateSplitTransactions({ // TODO: delegateAccountID will be threaded in PR 11 (https://github.com/Expensify/App/issues/66425) delegateAccountID: undefined, isTrackIntentUser, + formatPhoneNumber, }); let updateMoneyRequestParamsOnyxData: OnyxData = {}; diff --git a/src/libs/actions/Task.ts b/src/libs/actions/Task.ts index f842b96831f0..0dda3be0c64e 100644 --- a/src/libs/actions/Task.ts +++ b/src/libs/actions/Task.ts @@ -7,7 +7,6 @@ import type {CancelTaskParams, CompleteTaskParams, CreateTaskParams, EditTaskAss import {WRITE_COMMANDS} from '@libs/API/types'; import DateUtils from '@libs/DateUtils'; import * as ErrorUtils from '@libs/ErrorUtils'; -import * as LocalePhoneNumber from '@libs/LocalePhoneNumber'; import createDynamicRoute from '@libs/Navigation/helpers/dynamicRoutesUtils/createDynamicRoute'; import Navigation from '@libs/Navigation/Navigation'; import {getDBTimeWithSkew} from '@libs/NetworkState'; @@ -1097,7 +1096,12 @@ function startOutCreateTaskQuickAction(currentUserAccountID: number, reportID: s /** * Get the assignee data */ -function getAssignee(assigneeAccountID: number | undefined, personalDetails: OnyxEntry, translate: LocalizedTranslate): Assignee | undefined { +function getAssignee( + assigneeAccountID: number | undefined, + personalDetails: OnyxEntry, + translate: LocalizedTranslate, + formatPhoneNumber: LocaleContextProps['formatPhoneNumber'], +): Assignee | undefined { if (!assigneeAccountID) { return; } @@ -1114,7 +1118,7 @@ function getAssignee(assigneeAccountID: number | undefined, personalDetails: Ony return { icons: ReportUtils.getIconsForParticipants([details.accountID], personalDetails), - displayName: LocalePhoneNumber.formatPhoneNumber(PersonalDetailsUtils.temporaryGetDisplayNameOrDefault({passedPersonalDetails: details, translate})), + displayName: formatPhoneNumber(PersonalDetailsUtils.temporaryGetDisplayNameOrDefault({passedPersonalDetails: details, translate})), subtitle: details.login ?? '', }; } @@ -1129,6 +1133,7 @@ function getShareDestination( policy: OnyxEntry, conciergeReportID: string | undefined, translate: LocalizedTranslate, + formatPhoneNumber: LocaleContextProps['formatPhoneNumber'], reportAttributes?: OnyxTypes.ReportAttributesDerivedValue['reports'], ): ShareDestination { const isOneOnOneChat = ReportUtils.isOneOnOneChat(report); @@ -1140,7 +1145,7 @@ function getShareDestination( OptionsListUtils.getPersonalDetailsForAccountIDs(participants, personalDetails), isMultipleParticipant, localeCompare, - LocalePhoneNumber.formatPhoneNumber, + formatPhoneNumber, ); let subtitle = ''; @@ -1149,12 +1154,12 @@ function getShareDestination( const displayName = personalDetails?.[participantAccountID]?.displayName ?? ''; const login = personalDetails?.[participantAccountID]?.login ?? ''; - subtitle = LocalePhoneNumber.formatPhoneNumber(login || displayName); + subtitle = formatPhoneNumber(login || displayName); } else { subtitle = ReportUtils.getChatRoomSubtitle(report, policy, conciergeReportID, translate) ?? ''; } return { - icons: ReportUtils.getIcons(report, LocalePhoneNumber.formatPhoneNumber, translate, personalDetails, FallbackAvatar), + icons: ReportUtils.getIcons(report, formatPhoneNumber, translate, personalDetails, FallbackAvatar), displayName: getReportName(report, reportAttributes), subtitle, displayNamesWithTooltips, diff --git a/src/pages/Travel/TravelLegalNamePage.tsx b/src/pages/Travel/TravelLegalNamePage.tsx index 09a8375148eb..cd0bff196fa7 100644 --- a/src/pages/Travel/TravelLegalNamePage.tsx +++ b/src/pages/Travel/TravelLegalNamePage.tsx @@ -8,7 +8,6 @@ import useThemeStyles from '@hooks/useThemeStyles'; import {clearDraftValues} from '@libs/actions/FormActions'; import {updateLegalName} from '@libs/actions/PersonalDetails'; -import {formatPhoneNumber} from '@libs/LocalePhoneNumber'; import Navigation from '@libs/Navigation/Navigation'; import BaseLegalNamePage, {validateLegalName} from '@pages/settings/Profile/PersonalDetails/BaseLegalNamePage'; @@ -19,7 +18,7 @@ import INPUT_IDS from '@src/types/form/PersonalDetailsForm'; import React, {useEffect} from 'react'; function TravelLegalNamePage() { - const {translate} = useLocalize(); + const {translate, formatPhoneNumber} = useLocalize(); const styles = useThemeStyles(); const currentUserPersonalDetails = useCurrentUserPersonalDetails(); const [privatePersonalDetails] = useOnyx(ONYXKEYS.PRIVATE_PERSONAL_DETAILS); diff --git a/src/pages/iou/request/step/IOURequestStepCompanyInfo.tsx b/src/pages/iou/request/step/IOURequestStepCompanyInfo.tsx index 42763de1717e..4d63772a322b 100644 --- a/src/pages/iou/request/step/IOURequestStepCompanyInfo.tsx +++ b/src/pages/iou/request/step/IOURequestStepCompanyInfo.tsx @@ -48,7 +48,7 @@ function IOURequestStepCompanyInfo({route, report, transaction}: IOURequestStepC const {backTo, reportID} = route.params; const styles = useThemeStyles(); - const {translate} = useLocalize(); + const {translate, formatPhoneNumber} = useLocalize(); const {convertToDisplayString} = useCurrencyListActions(); const {inputCallbackRef} = useAutoFocusInput(); const currentUserPersonalDetails = useCurrentUserPersonalDetails(); @@ -120,6 +120,7 @@ function IOURequestStepCompanyInfo({route, report, transaction}: IOURequestStepC policyRecentlyUsedTags, isFromGlobalCreate, senderPolicyTags: policyTags ?? {}, + formatPhoneNumber, }); cleanupAndNavigateAfterExpenseCreate({ report: undefined, diff --git a/src/pages/iou/request/step/IOURequestStepScan/components/ScanSkipConfirmation.tsx b/src/pages/iou/request/step/IOURequestStepScan/components/ScanSkipConfirmation.tsx index 94e58b1b1224..76da89f949f3 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/components/ScanSkipConfirmation.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/components/ScanSkipConfirmation.tsx @@ -109,7 +109,7 @@ function ScanSkipConfirmation({report, action, iouType, reportID, transactionID, const [transactions] = useOptimisticDraftTransactions(transaction); const {isMultiScanEnabled} = useMultiScanState(); - const {translate} = useLocalize(); + const {translate, formatPhoneNumber} = useLocalize(); const {disableMultiScan} = useMultiScanActions(); const {setIsLoaderVisible} = useFullScreenLoaderActions(); const [startLocationPermissionFlow, setStartLocationPermissionFlow] = useState(false); @@ -235,6 +235,7 @@ function ScanSkipConfirmation({report, action, iouType, reportID, transactionID, ...splitBaseParams, shouldHandleNavigation: overrides.shouldHandleNavigation, shouldDeferForSearch: false, + formatPhoneNumber, }); cleanupAfterSkipConfirmSubmit(overrides.shouldHandleNavigation, { report, diff --git a/src/pages/iou/request/step/confirmation/useExpenseSubmission.ts b/src/pages/iou/request/step/confirmation/useExpenseSubmission.ts index 4e40e78e941b..ca10be573fc9 100644 --- a/src/pages/iou/request/step/confirmation/useExpenseSubmission.ts +++ b/src/pages/iou/request/step/confirmation/useExpenseSubmission.ts @@ -193,7 +193,7 @@ function useExpenseSubmission(params: UseExpenseSubmissionParams) { } = params; // Localization - const {translate, toLocaleDigit} = useLocalize(); + const {translate, toLocaleDigit, formatPhoneNumber} = useLocalize(); // Permissions const {isBetaEnabled} = usePermissions(); @@ -612,6 +612,7 @@ function useExpenseSubmission(params: UseExpenseSubmissionParams) { personalDetails, optimisticChatReportID, isTrackIntentUser, + formatPhoneNumber, }); const targetReportID = backToReport ?? activeReportID; // When backToReport exists we are creating the expense from chat, not the expense report, so no pending transaction registration needed. @@ -874,6 +875,7 @@ function useExpenseSubmission(params: UseExpenseSubmissionParams) { participantsPolicyTags, shouldHandleNavigation, shouldDeferForSearch: shouldDeferSplitForSearch, + formatPhoneNumber, }); } } @@ -915,6 +917,7 @@ function useExpenseSubmission(params: UseExpenseSubmissionParams) { shouldHandleNavigation, shouldDeferForSearch: shouldDeferSplitForSearch, isTrackIntentUser, + formatPhoneNumber, }); } markSubmitExpenseEnd(); @@ -953,6 +956,7 @@ function useExpenseSubmission(params: UseExpenseSubmissionParams) { shouldHandleNavigation, shouldDeferForSearch: shouldDeferSplitForSearch, isTrackIntentUser, + formatPhoneNumber, }); } markSubmitExpenseEnd(); @@ -977,6 +981,7 @@ function useExpenseSubmission(params: UseExpenseSubmissionParams) { isFromGlobalCreate: getIsFromGlobalCreate(transaction), policyRecentlyUsedTags, senderPolicyTags: senderWorkspacePolicyTags ?? {}, + formatPhoneNumber, }); if (shouldHandleNavigation) { cleanupAndNavigateAfterExpenseCreate({ diff --git a/src/pages/tasks/DynamicNewTaskPage.tsx b/src/pages/tasks/DynamicNewTaskPage.tsx index a4073f6ccd84..3b2f6ca80c4a 100644 --- a/src/pages/tasks/DynamicNewTaskPage.tsx +++ b/src/pages/tasks/DynamicNewTaskPage.tsx @@ -47,14 +47,16 @@ function DynamicNewTaskPage() { }); const styles = useThemeStyles(); const {translate, formatPhoneNumber, localeCompare} = useLocalize(); - const assignee = getAssignee(task?.assigneeAccountID ?? CONST.DEFAULT_NUMBER_ID, personalDetails, translate); + const assignee = getAssignee(task?.assigneeAccountID ?? CONST.DEFAULT_NUMBER_ID, personalDetails, translate, formatPhoneNumber); const assigneeTooltipDetails = getDisplayNamesWithTooltips( getPersonalDetailsForAccountIDs(task?.assigneeAccountID ? [task.assigneeAccountID] : [], personalDetails), false, localeCompare, formatPhoneNumber, ); - const shareDestination = task?.shareDestination ? getShareDestination(parentReport, personalDetails, localeCompare, policy, conciergeReportID, translate, reportAttributes) : undefined; + const shareDestination = task?.shareDestination + ? getShareDestination(parentReport, personalDetails, localeCompare, policy, conciergeReportID, translate, formatPhoneNumber, reportAttributes) + : undefined; const ancestors = useAncestors(parentReport); const taskKey = `${task?.assignee}|${task?.assigneeAccountID}|${task?.description}|${task?.parentReportID}|${task?.shareDestination}|${task?.title}`; const [error, setError] = useState<{message: string; taskKey: string}>({ From 88e5b9eaf7e588cde1ca3815c43f2ae2174d6a5a Mon Sep 17 00:00:00 2001 From: Maruf Sharifi Date: Wed, 15 Jul 2026 19:41:24 +0300 Subject: [PATCH 02/12] fixed type failure --- src/libs/actions/IOU/MoneyRequestBuilder.ts | 5 +++-- src/libs/actions/IOU/PerDiem.ts | 7 ++++--- src/libs/actions/IOU/SendInvoice.ts | 5 +++-- src/libs/actions/IOU/Split.ts | 14 ++++++++------ src/libs/actions/IOU/SplitTransactionUpdate.ts | 2 +- src/libs/actions/Task.ts | 14 ++++++++------ 6 files changed, 27 insertions(+), 20 deletions(-) diff --git a/src/libs/actions/IOU/MoneyRequestBuilder.ts b/src/libs/actions/IOU/MoneyRequestBuilder.ts index 6af32867d783..482f1852420b 100644 --- a/src/libs/actions/IOU/MoneyRequestBuilder.ts +++ b/src/libs/actions/IOU/MoneyRequestBuilder.ts @@ -226,7 +226,7 @@ type MoneyRequestInformationParams = { personalDetails: OnyxEntry; isTrackIntentUser: boolean | undefined; delegateAccountID: number | undefined; - formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; + formatPhoneNumber?: LocaleContextProps['formatPhoneNumber']; }; type MoneyRequestOptimisticParams = { @@ -1295,6 +1295,7 @@ function getMoneyRequestInformation(moneyRequestInformation: MoneyRequestInforma isTrackIntentUser, formatPhoneNumber, } = moneyRequestInformation; + const formatPhone = formatPhoneNumber ?? ((n: string) => n); const {payeeAccountID = currentUserAccountIDParam, payeeEmail = currentUserEmailParam, participant} = participantParams; const {policy, policyCategories, policyTagList, policyRecentlyUsedCategories, policyRecentlyUsedTags} = policyParams; @@ -1617,7 +1618,7 @@ function getMoneyRequestInformation(moneyRequestInformation: MoneyRequestInforma ? { [payerAccountID]: { accountID: payerAccountID, - displayName: formatPhoneNumber(optimisticPersonalDetailDisplayName), + displayName: formatPhone(optimisticPersonalDetailDisplayName), firstName: optimisticPersonalDetailFirstName, lastName: optimisticPersonalDetailLastName, login: participant.login, diff --git a/src/libs/actions/IOU/PerDiem.ts b/src/libs/actions/IOU/PerDiem.ts index fd3c915cd979..8c134760f209 100644 --- a/src/libs/actions/IOU/PerDiem.ts +++ b/src/libs/actions/IOU/PerDiem.ts @@ -244,7 +244,7 @@ type PerDiemExpenseInformation = { // TODO: delegateAccountID will be made required in PR 13 when all callers pass the value (https://github.com/Expensify/App/issues/66425) delegateAccountID?: number | undefined; isTrackIntentUser: boolean | undefined; - formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; + formatPhoneNumber?: LocaleContextProps['formatPhoneNumber']; }; type PerDiemExpenseInformationParams = { @@ -269,7 +269,7 @@ type PerDiemExpenseInformationParams = { // TODO: delegateAccountID will be made required in PR 13 when all callers pass the value (https://github.com/Expensify/App/issues/66425) delegateAccountID?: number | undefined; isTrackIntentUser: boolean | undefined; - formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; + formatPhoneNumber?: LocaleContextProps['formatPhoneNumber']; }; type PerDiemExpenseInformationForSelfDM = { @@ -329,6 +329,7 @@ function getPerDiemExpenseInformation(perDiemExpenseInformation: PerDiemExpenseI isTrackIntentUser, formatPhoneNumber, } = perDiemExpenseInformation; + const formatPhone = formatPhoneNumber ?? ((n: string) => n); const {payeeAccountID = currentUserAccountIDParam, payeeEmail = currentUserEmailParam, participant} = participantParams; const {policy, policyCategories, policyTagList, policyRecentlyUsedCategories, policyRecentlyUsedTags} = policyParams; const {destinations: recentlyUsedDestinations} = recentlyUsedParams; @@ -503,7 +504,7 @@ function getPerDiemExpenseInformation(perDiemExpenseInformation: PerDiemExpenseI accountID: payerAccountID, // Disabling this line since participant.displayName can be an empty string // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - displayName: formatPhoneNumber(participant.displayName || payerEmail), + displayName: formatPhone(participant.displayName || payerEmail), login: participant.login, isOptimisticPersonalDetail: true, }, diff --git a/src/libs/actions/IOU/SendInvoice.ts b/src/libs/actions/IOU/SendInvoice.ts index e66e34d48499..04d252665393 100644 --- a/src/libs/actions/IOU/SendInvoice.ts +++ b/src/libs/actions/IOU/SendInvoice.ts @@ -88,7 +88,7 @@ type SendInvoiceOptions = { senderPolicyTags: OnyxEntry; // TODO: delegateAccountID will be made required in PR 12 when all callers pass the value (https://github.com/Expensify/App/issues/66425) delegateAccountID?: number | undefined; - formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; + formatPhoneNumber?: LocaleContextProps['formatPhoneNumber']; }; type BuildOnyxDataForInvoiceParams = { @@ -595,6 +595,7 @@ function getSendInvoiceInformation({ delegateAccountID, formatPhoneNumber, }: SendInvoiceOptions): SendInvoiceInformation { + const formatPhone = formatPhoneNumber ?? ((n: string) => n); const {amount = 0, currency = '', created = '', merchant = '', category = '', tag = '', taxCode = '', taxAmount = 0, taxValue, billable, comment, participants} = transaction ?? {}; const trimmedComment = (comment?.comment ?? '').trim(); const senderWorkspaceID = participants?.find((participant) => participant?.isSender)?.policyID; @@ -663,7 +664,7 @@ function getSendInvoiceInformation({ const receiverLogin = receiverParticipant && 'login' in receiverParticipant && receiverParticipant.login ? receiverParticipant.login : ''; receiver = { accountID: receiverAccountID, - displayName: formatPhoneNumber(receiverLogin), + displayName: formatPhone(receiverLogin), login: receiverLogin, isOptimisticPersonalDetail: true, }; diff --git a/src/libs/actions/IOU/Split.ts b/src/libs/actions/IOU/Split.ts index 671c403543e1..916569761963 100644 --- a/src/libs/actions/IOU/Split.ts +++ b/src/libs/actions/IOU/Split.ts @@ -144,7 +144,7 @@ type CreateDistanceRequestInformation = { previousOdometerDraft?: OnyxEntry; delegateAccountID: number | undefined; isTrackIntentUser: boolean | undefined; - formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; + formatPhoneNumber?: LocaleContextProps['formatPhoneNumber']; }; type CreateSplitsTransactionParams = Omit & { @@ -171,7 +171,7 @@ type CreateSplitsAndOnyxDataParams = { // TODO: delegateAccountID will be made required in PR 11 when all callers pass the value (https://github.com/Expensify/App/issues/66425) delegateAccountID?: number | undefined; isTrackIntentUser: boolean | undefined; - formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; + formatPhoneNumber?: LocaleContextProps['formatPhoneNumber']; }; type StartSplitBilActionParams = { @@ -197,7 +197,7 @@ type StartSplitBilActionParams = { quickAction: OnyxEntry; policyRecentlyUsedCurrencies: string[]; participantsPolicyTags: Record; - formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; + formatPhoneNumber?: LocaleContextProps['formatPhoneNumber']; }; type SplitBillActionsParams = { @@ -233,7 +233,7 @@ type SplitBillActionsParams = { // TODO: delegateAccountID will be made required in PR 11 when all callers pass the value (https://github.com/Expensify/App/issues/66425) delegateAccountID?: number | undefined; isTrackIntentUser: boolean | undefined; - formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; + formatPhoneNumber?: LocaleContextProps['formatPhoneNumber']; }; type CompleteSplitBillInformation = { @@ -512,6 +512,7 @@ function startSplitBill({ shouldDeferForSearch = false, formatPhoneNumber, }: StartSplitBilActionParams) { + const formatPhone = formatPhoneNumber ?? ((n: string) => n); const currentUserEmailForIOUSplit = addSMSDomainIfPhoneNumber(currentUserLogin); const participantAccountIDs = participants.map((participant) => Number(participant.accountID)); const {splitChatReport, existingSplitChatReport} = getOrCreateOptimisticSplitChatReport(existingSplitChatReportID, participants, participantAccountIDs, currentUserAccountID); @@ -770,7 +771,7 @@ function startSplitBill({ accountID, // Disabling this line since participant.displayName can be an empty string // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - displayName: formatPhoneNumber(participant.displayName || email), + displayName: formatPhone(participant.displayName || email), // Disabling this line since participant.login can be an empty string // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing login: participant.login || participant.text, @@ -1437,6 +1438,7 @@ function createSplitsAndOnyxData({ isTrackIntentUser, formatPhoneNumber, }: CreateSplitsAndOnyxDataParams): SplitsAndOnyxData { + const formatPhone = formatPhoneNumber ?? ((n: string) => n); const currentUserEmailForIOUSplit = addSMSDomainIfPhoneNumber(currentUserLogin); const participantAccountIDs = participants.map((participant) => Number(participant.accountID)); @@ -1818,7 +1820,7 @@ function createSplitsAndOnyxData({ accountID, // Disabling this line since participant.displayName can be an empty string // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - displayName: formatPhoneNumber(participant.displayName || email), + displayName: formatPhone(participant.displayName || email), login: participant.login, isOptimisticPersonalDetail: true, }, diff --git a/src/libs/actions/IOU/SplitTransactionUpdate.ts b/src/libs/actions/IOU/SplitTransactionUpdate.ts index 305f0dea3746..4daa16a70a91 100644 --- a/src/libs/actions/IOU/SplitTransactionUpdate.ts +++ b/src/libs/actions/IOU/SplitTransactionUpdate.ts @@ -109,7 +109,7 @@ type UpdateSplitTransactionsParams = { expenseReport: OnyxEntry; isOffline: boolean; isTrackIntentUser: boolean | undefined; - formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; + formatPhoneNumber?: LocaleContextProps['formatPhoneNumber']; }; function updateSplitTransactions({ diff --git a/src/libs/actions/Task.ts b/src/libs/actions/Task.ts index 0dda3be0c64e..9d9249489c39 100644 --- a/src/libs/actions/Task.ts +++ b/src/libs/actions/Task.ts @@ -1100,8 +1100,9 @@ function getAssignee( assigneeAccountID: number | undefined, personalDetails: OnyxEntry, translate: LocalizedTranslate, - formatPhoneNumber: LocaleContextProps['formatPhoneNumber'], + formatPhoneNumber?: LocaleContextProps['formatPhoneNumber'], ): Assignee | undefined { + const formatPhone = formatPhoneNumber ?? ((n: string) => n); if (!assigneeAccountID) { return; } @@ -1118,7 +1119,7 @@ function getAssignee( return { icons: ReportUtils.getIconsForParticipants([details.accountID], personalDetails), - displayName: formatPhoneNumber(PersonalDetailsUtils.temporaryGetDisplayNameOrDefault({passedPersonalDetails: details, translate})), + displayName: formatPhone(PersonalDetailsUtils.temporaryGetDisplayNameOrDefault({passedPersonalDetails: details, translate})), subtitle: details.login ?? '', }; } @@ -1133,9 +1134,10 @@ function getShareDestination( policy: OnyxEntry, conciergeReportID: string | undefined, translate: LocalizedTranslate, - formatPhoneNumber: LocaleContextProps['formatPhoneNumber'], + formatPhoneNumber?: LocaleContextProps['formatPhoneNumber'], reportAttributes?: OnyxTypes.ReportAttributesDerivedValue['reports'], ): ShareDestination { + const formatPhone = formatPhoneNumber ?? ((n: string) => n); const isOneOnOneChat = ReportUtils.isOneOnOneChat(report); const participants = ReportUtils.getParticipantsAccountIDsForDisplay(report); @@ -1145,7 +1147,7 @@ function getShareDestination( OptionsListUtils.getPersonalDetailsForAccountIDs(participants, personalDetails), isMultipleParticipant, localeCompare, - formatPhoneNumber, + formatPhone, ); let subtitle = ''; @@ -1154,12 +1156,12 @@ function getShareDestination( const displayName = personalDetails?.[participantAccountID]?.displayName ?? ''; const login = personalDetails?.[participantAccountID]?.login ?? ''; - subtitle = formatPhoneNumber(login || displayName); + subtitle = formatPhone(login || displayName); } else { subtitle = ReportUtils.getChatRoomSubtitle(report, policy, conciergeReportID, translate) ?? ''; } return { - icons: ReportUtils.getIcons(report, formatPhoneNumber, translate, personalDetails, FallbackAvatar), + icons: ReportUtils.getIcons(report, formatPhone, translate, personalDetails, FallbackAvatar), displayName: getReportName(report, reportAttributes), subtitle, displayNamesWithTooltips, From ef27dd327fe640cbfc2124f5401eb6ad8d39cd6d Mon Sep 17 00:00:00 2001 From: Maruf Sharifi Date: Wed, 15 Jul 2026 20:58:09 +0300 Subject: [PATCH 03/12] Fixed lint failure --- src/hooks/useDeleteTransactions.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hooks/useDeleteTransactions.ts b/src/hooks/useDeleteTransactions.ts index 0eeb3cdab076..ca84f3ff9346 100644 --- a/src/hooks/useDeleteTransactions.ts +++ b/src/hooks/useDeleteTransactions.ts @@ -1,7 +1,5 @@ import {useSearchQueryContext, useSearchResultsContext} from '@components/Search/SearchContext'; -import useLocalize from '@hooks/useLocalize'; - import {deleteMoneyRequest} from '@libs/actions/IOU/DeleteMoneyRequest'; import {getIOUActionForTransactions} from '@libs/actions/IOU/Duplicate'; import {getIOURequestPolicyID} from '@libs/actions/IOU/MoneyRequest'; @@ -33,6 +31,7 @@ import {useCallback} from 'react'; import useCurrentUserPersonalDetails from './useCurrentUserPersonalDetails'; import useEnvironment from './useEnvironment'; +import useLocalize from './useLocalize'; import useNetwork from './useNetwork'; import useOnyx from './useOnyx'; import usePermissions from './usePermissions'; @@ -402,6 +401,7 @@ function useDeleteTransactions({report, reportActions, policy}: UseDeleteTransac isProduction, personalPolicy?.outputCurrency, isTrackIntentUser, + formatPhoneNumber, ], ); From 5201eddd63a8fed41cbbb4d12647d9bcded2d927 Mon Sep 17 00:00:00 2001 From: Maruf Sharifi Date: Thu, 16 Jul 2026 08:28:26 +0300 Subject: [PATCH 04/12] Make formatPhoneNumber required in IOU and Task types and update all callers --- src/libs/actions/IOU/PerDiem.ts | 4 +- src/libs/actions/IOU/SendInvoice.ts | 2 +- src/libs/actions/IOU/Split.ts | 8 +-- .../actions/IOU/SplitTransactionUpdate.ts | 2 +- src/libs/actions/Task.ts | 4 +- .../IOU/GetMoneyRequestInformationTest.ts | 1 + tests/actions/IOU/PerDiemTest.ts | 8 +++ tests/actions/IOU/SplitReportTotalsTest.ts | 2 + tests/actions/IOUTest/SendInvoiceTest.ts | 5 ++ tests/actions/IOUTest/SplitSelfDMTest.ts | 6 ++ tests/actions/IOUTest/SplitTest.ts | 55 +++++++++++++++++++ 11 files changed, 87 insertions(+), 10 deletions(-) diff --git a/src/libs/actions/IOU/PerDiem.ts b/src/libs/actions/IOU/PerDiem.ts index 8c134760f209..01068bfb06c2 100644 --- a/src/libs/actions/IOU/PerDiem.ts +++ b/src/libs/actions/IOU/PerDiem.ts @@ -244,7 +244,7 @@ type PerDiemExpenseInformation = { // TODO: delegateAccountID will be made required in PR 13 when all callers pass the value (https://github.com/Expensify/App/issues/66425) delegateAccountID?: number | undefined; isTrackIntentUser: boolean | undefined; - formatPhoneNumber?: LocaleContextProps['formatPhoneNumber']; + formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; }; type PerDiemExpenseInformationParams = { @@ -269,7 +269,7 @@ type PerDiemExpenseInformationParams = { // TODO: delegateAccountID will be made required in PR 13 when all callers pass the value (https://github.com/Expensify/App/issues/66425) delegateAccountID?: number | undefined; isTrackIntentUser: boolean | undefined; - formatPhoneNumber?: LocaleContextProps['formatPhoneNumber']; + formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; }; type PerDiemExpenseInformationForSelfDM = { diff --git a/src/libs/actions/IOU/SendInvoice.ts b/src/libs/actions/IOU/SendInvoice.ts index 04d252665393..b0f75a6e89eb 100644 --- a/src/libs/actions/IOU/SendInvoice.ts +++ b/src/libs/actions/IOU/SendInvoice.ts @@ -88,7 +88,7 @@ type SendInvoiceOptions = { senderPolicyTags: OnyxEntry; // TODO: delegateAccountID will be made required in PR 12 when all callers pass the value (https://github.com/Expensify/App/issues/66425) delegateAccountID?: number | undefined; - formatPhoneNumber?: LocaleContextProps['formatPhoneNumber']; + formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; }; type BuildOnyxDataForInvoiceParams = { diff --git a/src/libs/actions/IOU/Split.ts b/src/libs/actions/IOU/Split.ts index 916569761963..89ff4eee5ee8 100644 --- a/src/libs/actions/IOU/Split.ts +++ b/src/libs/actions/IOU/Split.ts @@ -144,7 +144,7 @@ type CreateDistanceRequestInformation = { previousOdometerDraft?: OnyxEntry; delegateAccountID: number | undefined; isTrackIntentUser: boolean | undefined; - formatPhoneNumber?: LocaleContextProps['formatPhoneNumber']; + formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; }; type CreateSplitsTransactionParams = Omit & { @@ -171,7 +171,7 @@ type CreateSplitsAndOnyxDataParams = { // TODO: delegateAccountID will be made required in PR 11 when all callers pass the value (https://github.com/Expensify/App/issues/66425) delegateAccountID?: number | undefined; isTrackIntentUser: boolean | undefined; - formatPhoneNumber?: LocaleContextProps['formatPhoneNumber']; + formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; }; type StartSplitBilActionParams = { @@ -197,7 +197,7 @@ type StartSplitBilActionParams = { quickAction: OnyxEntry; policyRecentlyUsedCurrencies: string[]; participantsPolicyTags: Record; - formatPhoneNumber?: LocaleContextProps['formatPhoneNumber']; + formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; }; type SplitBillActionsParams = { @@ -233,7 +233,7 @@ type SplitBillActionsParams = { // TODO: delegateAccountID will be made required in PR 11 when all callers pass the value (https://github.com/Expensify/App/issues/66425) delegateAccountID?: number | undefined; isTrackIntentUser: boolean | undefined; - formatPhoneNumber?: LocaleContextProps['formatPhoneNumber']; + formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; }; type CompleteSplitBillInformation = { diff --git a/src/libs/actions/IOU/SplitTransactionUpdate.ts b/src/libs/actions/IOU/SplitTransactionUpdate.ts index 4daa16a70a91..305f0dea3746 100644 --- a/src/libs/actions/IOU/SplitTransactionUpdate.ts +++ b/src/libs/actions/IOU/SplitTransactionUpdate.ts @@ -109,7 +109,7 @@ type UpdateSplitTransactionsParams = { expenseReport: OnyxEntry; isOffline: boolean; isTrackIntentUser: boolean | undefined; - formatPhoneNumber?: LocaleContextProps['formatPhoneNumber']; + formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; }; function updateSplitTransactions({ diff --git a/src/libs/actions/Task.ts b/src/libs/actions/Task.ts index 9d9249489c39..3bfb8bd45068 100644 --- a/src/libs/actions/Task.ts +++ b/src/libs/actions/Task.ts @@ -1100,7 +1100,7 @@ function getAssignee( assigneeAccountID: number | undefined, personalDetails: OnyxEntry, translate: LocalizedTranslate, - formatPhoneNumber?: LocaleContextProps['formatPhoneNumber'], + formatPhoneNumber: LocaleContextProps['formatPhoneNumber'], ): Assignee | undefined { const formatPhone = formatPhoneNumber ?? ((n: string) => n); if (!assigneeAccountID) { @@ -1134,7 +1134,7 @@ function getShareDestination( policy: OnyxEntry, conciergeReportID: string | undefined, translate: LocalizedTranslate, - formatPhoneNumber?: LocaleContextProps['formatPhoneNumber'], + formatPhoneNumber: LocaleContextProps['formatPhoneNumber'], reportAttributes?: OnyxTypes.ReportAttributesDerivedValue['reports'], ): ShareDestination { const formatPhone = formatPhoneNumber ?? ((n: string) => n); diff --git a/tests/actions/IOU/GetMoneyRequestInformationTest.ts b/tests/actions/IOU/GetMoneyRequestInformationTest.ts index dd76fa00547b..802608cef452 100644 --- a/tests/actions/IOU/GetMoneyRequestInformationTest.ts +++ b/tests/actions/IOU/GetMoneyRequestInformationTest.ts @@ -70,6 +70,7 @@ const baseParams = { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, } as const; describe('getMoneyRequestInformation', () => { diff --git a/tests/actions/IOU/PerDiemTest.ts b/tests/actions/IOU/PerDiemTest.ts index 7a827cb6d056..f80cee6e468d 100644 --- a/tests/actions/IOU/PerDiemTest.ts +++ b/tests/actions/IOU/PerDiemTest.ts @@ -327,6 +327,7 @@ describe('PerDiem', () => { betas: [CONST.BETAS.ALL], personalDetails: {[mockParticipantParams.payeeAccountID]: {accountID: mockParticipantParams.payeeAccountID, login: 'payee@example.com'}}, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); expect(result.onyxData).toBeDefined(); @@ -418,6 +419,7 @@ describe('PerDiem', () => { betas: [CONST.BETAS.ALL], personalDetails: {[mockParticipant.accountID]: {accountID: mockParticipant.accountID, login: 'existing@example.com'}}, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); // Then: Verify the result structure and key values @@ -553,6 +555,7 @@ describe('PerDiem', () => { betas: [CONST.BETAS.ALL], personalDetails: {[mockParticipant.accountID]: {accountID: mockParticipant.accountID, login: 'existing@example.com'}}, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); // Then: Verify the result uses existing chat report @@ -642,6 +645,7 @@ describe('PerDiem', () => { betas: [CONST.BETAS.ALL], personalDetails: {[mockParticipant.accountID]: {accountID: mockParticipant.accountID, login: 'existing@example.com'}}, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); // Then: Verify policy expense chat handling @@ -718,6 +722,7 @@ describe('PerDiem', () => { betas: [CONST.BETAS.ALL], personalDetails: {[RORY_ACCOUNT_ID]: {accountID: RORY_ACCOUNT_ID, login: RORY_EMAIL}}, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -787,6 +792,7 @@ describe('PerDiem', () => { personalDetails: {[RORY_ACCOUNT_ID]: {accountID: RORY_ACCOUNT_ID, login: RORY_EMAIL}}, optimisticTransactionID, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -861,6 +867,7 @@ describe('PerDiem', () => { betas: [CONST.BETAS.ALL], personalDetails: personalDetailsList, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); // Then the result should be valid (personalDetails is correctly passed through the chain) @@ -926,6 +933,7 @@ describe('PerDiem', () => { betas: [CONST.BETAS.ALL], personalDetails: personalDetailsList, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); diff --git a/tests/actions/IOU/SplitReportTotalsTest.ts b/tests/actions/IOU/SplitReportTotalsTest.ts index f4a808d61990..d8d697c0a9e9 100644 --- a/tests/actions/IOU/SplitReportTotalsTest.ts +++ b/tests/actions/IOU/SplitReportTotalsTest.ts @@ -506,6 +506,7 @@ describe('actions/IOU', () => { personalDetails: mockPersonalDetails, participantsPolicyTags: overrides.participantsPolicyTags ?? {}, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); it('returns valid splitData with chatReportID, transactionID, and reportActionID', () => { @@ -770,6 +771,7 @@ describe('actions/IOU', () => { expenseReport: {reportID: EXPENSE_REPORT_ID, parentReportID: 'parent-report-1', chatReportID: 'chat-report-1'}, isOffline: false, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, ...overrides, }; } diff --git a/tests/actions/IOUTest/SendInvoiceTest.ts b/tests/actions/IOUTest/SendInvoiceTest.ts index 8683ed262b2b..131dbe9de639 100644 --- a/tests/actions/IOUTest/SendInvoiceTest.ts +++ b/tests/actions/IOUTest/SendInvoiceTest.ts @@ -624,6 +624,7 @@ describe('actions/SendInvoice', () => { companyName, companyWebsite, senderPolicyTags: undefined, + formatPhoneNumber: (n: string) => n, }); // Then a new invoice chat is created instead of incorrectly using the invoice chat which has been converted from individual to business @@ -652,6 +653,7 @@ describe('actions/SendInvoice', () => { transaction, policyRecentlyUsedCurrencies: initialCurrencies, senderPolicyTags: undefined, + formatPhoneNumber: (n: string) => n, }); mockFetch?.fail?.(); @@ -692,6 +694,7 @@ describe('actions/SendInvoice', () => { policyRecentlyUsedCurrencies: [], policyRecentlyUsedCategories, senderPolicyTags: undefined, + formatPhoneNumber: (n: string) => n, }); // Then onyxData should be passed to API.write @@ -733,6 +736,7 @@ describe('actions/SendInvoice', () => { orderWeight: 0, }, }, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -768,6 +772,7 @@ describe('actions/SendInvoice', () => { policyRecentlyUsedCurrencies: [], invoiceChatReportID: preGeneratedReportID, senderPolicyTags: undefined, + formatPhoneNumber: (n: string) => n, }); expect(writeSpy).toHaveBeenCalledWith( diff --git a/tests/actions/IOUTest/SplitSelfDMTest.ts b/tests/actions/IOUTest/SplitSelfDMTest.ts index e33379114fd5..6ae112c01919 100644 --- a/tests/actions/IOUTest/SplitSelfDMTest.ts +++ b/tests/actions/IOUTest/SplitSelfDMTest.ts @@ -220,6 +220,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow - selfDM', () => { expenseReport: undefined, isOffline: false, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -309,6 +310,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow - selfDM', () => { expenseReport: undefined, isOffline: false, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -419,6 +421,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow - selfDM', () => { expenseReport: undefined, isOffline: false, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -514,6 +517,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow - selfDM', () => { expenseReport: undefined, isOffline: false, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -575,6 +579,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow - selfDM', () => { expenseReport: undefined, isOffline: false, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -667,6 +672,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow - selfDM', () => { expenseReport: undefined, isOffline: false, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); diff --git a/tests/actions/IOUTest/SplitTest.ts b/tests/actions/IOUTest/SplitTest.ts index e2e8c5f9481b..856545d3ddd3 100644 --- a/tests/actions/IOUTest/SplitTest.ts +++ b/tests/actions/IOUTest/SplitTest.ts @@ -413,6 +413,7 @@ describe('split expense', () => { betas: [CONST.BETAS.ALL], personalDetails: mockPersonalDetails, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }, ); return waitForBatchedUpdates(); @@ -749,6 +750,7 @@ describe('split expense', () => { betas: [CONST.BETAS.ALL], personalDetails: mockPersonalDetails, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -799,6 +801,7 @@ describe('split expense', () => { betas: [CONST.BETAS.ALL], personalDetails: mockPersonalDetails, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -823,6 +826,7 @@ describe('split expense', () => { betas: [CONST.BETAS.ALL], personalDetails: mockPersonalDetails, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -854,6 +858,7 @@ describe('split expense', () => { betas: [CONST.BETAS.ALL], personalDetails: mockPersonalDetails, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -890,6 +895,7 @@ describe('split expense', () => { betas: [CONST.BETAS.ALL], personalDetails: mockPersonalDetails, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -912,6 +918,7 @@ describe('split expense', () => { betas: [CONST.BETAS.ALL], personalDetails: mockPersonalDetails, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -978,6 +985,7 @@ describe('split expense', () => { betas: [CONST.BETAS.ALL], personalDetails: mockPersonalDetails, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -1029,6 +1037,7 @@ describe('split expense', () => { betas: [CONST.BETAS.ALL], personalDetails: mockPersonalDetails, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -1091,6 +1100,7 @@ describe('split expense', () => { betas: [CONST.BETAS.ALL], personalDetails: mockPersonalDetails, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); waitForBatchedUpdates(); @@ -1141,6 +1151,7 @@ describe('split expense', () => { policyRecentlyUsedCurrencies: [], policyRecentlyUsedTags: undefined, participantsPolicyTags, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -1174,6 +1185,7 @@ describe('split expense', () => { betas: [CONST.BETAS.ALL], personalDetails: mockPersonalDetails, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, sessionEmail: RORY_EMAIL, }); @@ -1318,6 +1330,7 @@ describe('split expense', () => { expenseReport: reports.expenseReport, isOffline: false, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -1386,6 +1399,7 @@ describe('split expense', () => { betas: [CONST.BETAS.ALL], personalDetails: testPersonalDetails, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -1448,6 +1462,7 @@ describe('split expense', () => { betas: [CONST.BETAS.ALL], personalDetails: participantPersonalDetails, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -1517,6 +1532,7 @@ describe('split expense', () => { quickAction: undefined, policyRecentlyUsedCurrencies: [], participantsPolicyTags, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -1586,6 +1602,7 @@ describe('split expense', () => { betas: [CONST.BETAS.ALL], personalDetails: completeSplitPersonalDetails, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, sessionEmail: RORY_EMAIL, }); @@ -1632,6 +1649,7 @@ describe('startSplitBill', () => { quickAction: {}, policyRecentlyUsedCurrencies: [], participantsPolicyTags, + formatPhoneNumber: (n: string) => n, }); waitForBatchedUpdates(); @@ -1676,6 +1694,7 @@ describe('startSplitBill', () => { policyRecentlyUsedCurrencies: [], policyRecentlyUsedTags: undefined, participantsPolicyTags, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -1723,6 +1742,7 @@ describe('startSplitBill', () => { policyRecentlyUsedCurrencies: [], policyRecentlyUsedTags: undefined, participantsPolicyTags, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -1840,6 +1860,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { expenseReport: reports.expenseReport, isOffline: false, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -1962,6 +1983,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { expenseReport: reports.expenseReport, isOffline: false, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -2096,6 +2118,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { expenseReport: reports.expenseReport, isOffline: false, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -2176,6 +2199,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -2266,6 +2290,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { expenseReport: reports.expenseReport, isOffline: false, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -2329,6 +2354,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { expenseReport: reports.expenseReport, isOffline: false, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -2408,6 +2434,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -2498,6 +2525,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { expenseReport: reports.expenseReport, isOffline: false, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -2608,6 +2636,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { expenseReport: reports.expenseReport, isOffline: false, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -2786,6 +2815,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { expenseReport: reports1.expenseReport, isOffline: false, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -2923,6 +2953,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { expenseReport: reports2.expenseReport, isOffline: false, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -3000,6 +3031,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); await getOnyxData({ @@ -3112,6 +3144,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { expenseReport: reports.expenseReport, isOffline: false, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -3182,6 +3215,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); await getOnyxData({ @@ -3294,6 +3328,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { expenseReport: reports.expenseReport, isOffline: false, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -3369,6 +3404,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -3490,6 +3526,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { expenseReport: reports.expenseReport, isOffline: false, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -3566,6 +3603,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -3709,6 +3747,7 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { expenseReport: reports.expenseReport, isOffline: false, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -3828,6 +3867,7 @@ describe('updateSplitTransactions', () => { existingTransactionDraft: undefined, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -3897,6 +3937,7 @@ describe('updateSplitTransactions', () => { expenseReport: reports.expenseReport, isOffline: false, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -3965,6 +4006,7 @@ describe('updateSplitTransactions', () => { draftTransactionIDs: [], delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -4034,6 +4076,7 @@ describe('updateSplitTransactions', () => { expenseReport: reports.expenseReport, isOffline: true, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -4102,6 +4145,7 @@ describe('updateSplitTransactions', () => { existingTransactionDraft: undefined, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -4169,6 +4213,7 @@ describe('updateSplitTransactions', () => { expenseReport: reports.expenseReport, isOffline: false, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -4250,6 +4295,7 @@ describe('updateSplitTransactions', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -4353,6 +4399,7 @@ describe('updateSplitTransactions', () => { expenseReport: reports.expenseReport, isOffline: false, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -4419,6 +4466,7 @@ describe('updateSplitTransactions', () => { expenseReport: reports.expenseReport, isOffline: false, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); const updateSplitTransactionCall = writeSpy.mock.calls.find(([command]) => command === WRITE_COMMANDS.UPDATE_SPLIT_TRANSACTION); @@ -4679,6 +4727,7 @@ describe('updateSplitTransactions', () => { expenseReport: reports.expenseReport, isOffline: false, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -4792,6 +4841,7 @@ describe('updateSplitTransactions', () => { expenseReport: reports.expenseReport, isOffline: false, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -4869,6 +4919,7 @@ describe('updateSplitTransactions', () => { expenseReport: reports.expenseReport, isOffline: false, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -4939,6 +4990,7 @@ describe('updateSplitTransactions', () => { expenseReport: reports.expenseReport, isOffline: false, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -5014,6 +5066,7 @@ describe('updateSplitTransactions', () => { expenseReport: reports.expenseReport, isOffline: false, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -5084,6 +5137,7 @@ describe('updateSplitTransactions', () => { expenseReport: reports.expenseReport, isOffline: false, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -7575,6 +7629,7 @@ describe('createDistanceRequest', () => { betas: [CONST.BETAS.ALL], delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber: (n: string) => n, }; } From d82a2aa6d62ac3b192521da9e777b166917c3895 Mon Sep 17 00:00:00 2001 From: Maruf Sharifi Date: Thu, 16 Jul 2026 09:22:36 +0300 Subject: [PATCH 05/12] Removed duplicated formatPhoneNumber fallback --- src/libs/actions/IOU/MoneyRequestBuilder.ts | 8 ++------ src/libs/actions/IOU/PerDiem.ts | 3 +-- src/libs/actions/IOU/SendInvoice.ts | 3 +-- src/libs/actions/IOU/Split.ts | 6 ++---- src/libs/actions/Task.ts | 10 ++++------ 5 files changed, 10 insertions(+), 20 deletions(-) diff --git a/src/libs/actions/IOU/MoneyRequestBuilder.ts b/src/libs/actions/IOU/MoneyRequestBuilder.ts index 63ef797f99e4..a2755ed5e3e1 100644 --- a/src/libs/actions/IOU/MoneyRequestBuilder.ts +++ b/src/libs/actions/IOU/MoneyRequestBuilder.ts @@ -1,10 +1,9 @@ -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'; @@ -226,7 +225,6 @@ type MoneyRequestInformationParams = { personalDetails: OnyxEntry; isTrackIntentUser: boolean | undefined; delegateAccountID: number | undefined; - formatPhoneNumber?: LocaleContextProps['formatPhoneNumber']; }; type MoneyRequestOptimisticParams = { @@ -1293,9 +1291,7 @@ function getMoneyRequestInformation(moneyRequestInformation: MoneyRequestInforma betas, delegateAccountID, isTrackIntentUser, - formatPhoneNumber, } = moneyRequestInformation; - const formatPhone = formatPhoneNumber ?? ((n: string) => n); const {payeeAccountID = currentUserAccountIDParam, payeeEmail = currentUserEmailParam, participant} = participantParams; const {policy, policyCategories, policyTagList, policyRecentlyUsedCategories, policyRecentlyUsedTags} = policyParams; @@ -1618,7 +1614,7 @@ function getMoneyRequestInformation(moneyRequestInformation: MoneyRequestInforma ? { [payerAccountID]: { accountID: payerAccountID, - displayName: formatPhone(optimisticPersonalDetailDisplayName), + displayName: formatPhoneNumber(optimisticPersonalDetailDisplayName), firstName: optimisticPersonalDetailFirstName, lastName: optimisticPersonalDetailLastName, login: participant.login, diff --git a/src/libs/actions/IOU/PerDiem.ts b/src/libs/actions/IOU/PerDiem.ts index 01068bfb06c2..fd3c915cd979 100644 --- a/src/libs/actions/IOU/PerDiem.ts +++ b/src/libs/actions/IOU/PerDiem.ts @@ -329,7 +329,6 @@ function getPerDiemExpenseInformation(perDiemExpenseInformation: PerDiemExpenseI isTrackIntentUser, formatPhoneNumber, } = perDiemExpenseInformation; - const formatPhone = formatPhoneNumber ?? ((n: string) => n); const {payeeAccountID = currentUserAccountIDParam, payeeEmail = currentUserEmailParam, participant} = participantParams; const {policy, policyCategories, policyTagList, policyRecentlyUsedCategories, policyRecentlyUsedTags} = policyParams; const {destinations: recentlyUsedDestinations} = recentlyUsedParams; @@ -504,7 +503,7 @@ function getPerDiemExpenseInformation(perDiemExpenseInformation: PerDiemExpenseI accountID: payerAccountID, // Disabling this line since participant.displayName can be an empty string // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - displayName: formatPhone(participant.displayName || payerEmail), + displayName: formatPhoneNumber(participant.displayName || payerEmail), login: participant.login, isOptimisticPersonalDetail: true, }, diff --git a/src/libs/actions/IOU/SendInvoice.ts b/src/libs/actions/IOU/SendInvoice.ts index b0f75a6e89eb..e66e34d48499 100644 --- a/src/libs/actions/IOU/SendInvoice.ts +++ b/src/libs/actions/IOU/SendInvoice.ts @@ -595,7 +595,6 @@ function getSendInvoiceInformation({ delegateAccountID, formatPhoneNumber, }: SendInvoiceOptions): SendInvoiceInformation { - const formatPhone = formatPhoneNumber ?? ((n: string) => n); const {amount = 0, currency = '', created = '', merchant = '', category = '', tag = '', taxCode = '', taxAmount = 0, taxValue, billable, comment, participants} = transaction ?? {}; const trimmedComment = (comment?.comment ?? '').trim(); const senderWorkspaceID = participants?.find((participant) => participant?.isSender)?.policyID; @@ -664,7 +663,7 @@ function getSendInvoiceInformation({ const receiverLogin = receiverParticipant && 'login' in receiverParticipant && receiverParticipant.login ? receiverParticipant.login : ''; receiver = { accountID: receiverAccountID, - displayName: formatPhone(receiverLogin), + displayName: formatPhoneNumber(receiverLogin), login: receiverLogin, isOptimisticPersonalDetail: true, }; diff --git a/src/libs/actions/IOU/Split.ts b/src/libs/actions/IOU/Split.ts index 50e6ba7cbbae..c939be28e392 100644 --- a/src/libs/actions/IOU/Split.ts +++ b/src/libs/actions/IOU/Split.ts @@ -513,7 +513,6 @@ function startSplitBill({ formatPhoneNumber, delegateAccountID, }: StartSplitBilActionParams) { - const formatPhone = formatPhoneNumber ?? ((n: string) => n); const currentUserEmailForIOUSplit = addSMSDomainIfPhoneNumber(currentUserLogin); const participantAccountIDs = participants.map((participant) => Number(participant.accountID)); const {splitChatReport, existingSplitChatReport} = getOrCreateOptimisticSplitChatReport(existingSplitChatReportID, participants, participantAccountIDs, currentUserAccountID); @@ -772,7 +771,7 @@ function startSplitBill({ accountID, // Disabling this line since participant.displayName can be an empty string // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - displayName: formatPhone(participant.displayName || email), + displayName: formatPhoneNumber(participant.displayName || email), // Disabling this line since participant.login can be an empty string // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing login: participant.login || participant.text, @@ -1437,7 +1436,6 @@ function createSplitsAndOnyxData({ isTrackIntentUser, formatPhoneNumber, }: CreateSplitsAndOnyxDataParams): SplitsAndOnyxData { - const formatPhone = formatPhoneNumber ?? ((n: string) => n); const currentUserEmailForIOUSplit = addSMSDomainIfPhoneNumber(currentUserLogin); const participantAccountIDs = participants.map((participant) => Number(participant.accountID)); @@ -1819,7 +1817,7 @@ function createSplitsAndOnyxData({ accountID, // Disabling this line since participant.displayName can be an empty string // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - displayName: formatPhone(participant.displayName || email), + displayName: formatPhoneNumber(participant.displayName || email), login: participant.login, isOptimisticPersonalDetail: true, }, diff --git a/src/libs/actions/Task.ts b/src/libs/actions/Task.ts index 3bfb8bd45068..0dda3be0c64e 100644 --- a/src/libs/actions/Task.ts +++ b/src/libs/actions/Task.ts @@ -1102,7 +1102,6 @@ function getAssignee( translate: LocalizedTranslate, formatPhoneNumber: LocaleContextProps['formatPhoneNumber'], ): Assignee | undefined { - const formatPhone = formatPhoneNumber ?? ((n: string) => n); if (!assigneeAccountID) { return; } @@ -1119,7 +1118,7 @@ function getAssignee( return { icons: ReportUtils.getIconsForParticipants([details.accountID], personalDetails), - displayName: formatPhone(PersonalDetailsUtils.temporaryGetDisplayNameOrDefault({passedPersonalDetails: details, translate})), + displayName: formatPhoneNumber(PersonalDetailsUtils.temporaryGetDisplayNameOrDefault({passedPersonalDetails: details, translate})), subtitle: details.login ?? '', }; } @@ -1137,7 +1136,6 @@ function getShareDestination( formatPhoneNumber: LocaleContextProps['formatPhoneNumber'], reportAttributes?: OnyxTypes.ReportAttributesDerivedValue['reports'], ): ShareDestination { - const formatPhone = formatPhoneNumber ?? ((n: string) => n); const isOneOnOneChat = ReportUtils.isOneOnOneChat(report); const participants = ReportUtils.getParticipantsAccountIDsForDisplay(report); @@ -1147,7 +1145,7 @@ function getShareDestination( OptionsListUtils.getPersonalDetailsForAccountIDs(participants, personalDetails), isMultipleParticipant, localeCompare, - formatPhone, + formatPhoneNumber, ); let subtitle = ''; @@ -1156,12 +1154,12 @@ function getShareDestination( const displayName = personalDetails?.[participantAccountID]?.displayName ?? ''; const login = personalDetails?.[participantAccountID]?.login ?? ''; - subtitle = formatPhone(login || displayName); + subtitle = formatPhoneNumber(login || displayName); } else { subtitle = ReportUtils.getChatRoomSubtitle(report, policy, conciergeReportID, translate) ?? ''; } return { - icons: ReportUtils.getIcons(report, formatPhone, translate, personalDetails, FallbackAvatar), + icons: ReportUtils.getIcons(report, formatPhoneNumber, translate, personalDetails, FallbackAvatar), displayName: getReportName(report, reportAttributes), subtitle, displayNamesWithTooltips, From 7f68a34a0d4bec0853f8fe62e404953aee2783b9 Mon Sep 17 00:00:00 2001 From: Maruf Sharifi Date: Thu, 16 Jul 2026 09:54:16 +0300 Subject: [PATCH 06/12] Fixed type failure --- tests/actions/IOUTest/SplitTest.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/actions/IOUTest/SplitTest.ts b/tests/actions/IOUTest/SplitTest.ts index e68013dde98b..a7aa331cdfde 100644 --- a/tests/actions/IOUTest/SplitTest.ts +++ b/tests/actions/IOUTest/SplitTest.ts @@ -8211,6 +8211,7 @@ describe('startSplitBill delegateAccountID forwarding', () => { policyRecentlyUsedTags: undefined, participantsPolicyTags, delegateAccountID: DELEGATE_ACCOUNT_ID, + formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); From 39569d51e9d8b1fc21d739ade441cdc2ca599210 Mon Sep 17 00:00:00 2001 From: Maruf Sharifi Date: Thu, 16 Jul 2026 16:37:11 +0300 Subject: [PATCH 07/12] Remove Onyx.connect for Split expense and Travel from LocalePhoneNumber --- src/hooks/useDeleteTransactions.ts | 4 -- src/libs/actions/IOU/PerDiem.ts | 8 +--- src/libs/actions/IOU/SendInvoice.ts | 7 +-- src/libs/actions/IOU/Split.ts | 47 ++++++++----------- .../actions/IOU/SplitTransactionUpdate.ts | 10 ++-- src/libs/actions/Task.ts | 17 +++---- .../step/IOURequestStepCompanyInfo.tsx | 3 +- src/pages/tasks/DynamicNewTaskPage.tsx | 6 +-- .../IOU/GetMoneyRequestInformationTest.ts | 1 - tests/actions/IOU/PerDiemTest.ts | 8 ---- tests/actions/IOUTest/SendInvoiceTest.ts | 5 -- 11 files changed, 34 insertions(+), 82 deletions(-) diff --git a/src/hooks/useDeleteTransactions.ts b/src/hooks/useDeleteTransactions.ts index 8ee5d97f2f6d..7cf9975cd254 100644 --- a/src/hooks/useDeleteTransactions.ts +++ b/src/hooks/useDeleteTransactions.ts @@ -32,7 +32,6 @@ 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'; @@ -73,7 +72,6 @@ function redistributeRemainingPerDiemSplitExpenses(splitExpenses: SplitExpense[] * All data must be provided through function parameters */ function useDeleteTransactions({report, reportActions, policy}: UseDeleteTransactionsParams) { - const {formatPhoneNumber} = useLocalize(); const {currentSearchResults} = useSearchResultsContext(); const {currentSearchQueryJSON} = useSearchQueryContext(); const [allTransactions] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION); @@ -328,7 +326,6 @@ function useDeleteTransactions({report, reportActions, policy}: UseDeleteTransac isOffline, delegateAccountID, isTrackIntentUser, - formatPhoneNumber, }); } @@ -405,7 +402,6 @@ function useDeleteTransactions({report, reportActions, policy}: UseDeleteTransac personalPolicy?.outputCurrency, delegateAccountID, isTrackIntentUser, - formatPhoneNumber, ], ); diff --git a/src/libs/actions/IOU/PerDiem.ts b/src/libs/actions/IOU/PerDiem.ts index fd3c915cd979..9292a1f7c02b 100644 --- a/src/libs/actions/IOU/PerDiem.ts +++ b/src/libs/actions/IOU/PerDiem.ts @@ -1,5 +1,3 @@ -import type {LocaleContextProps} from '@components/LocaleContextProvider'; - import * as API from '@libs/API'; import type {CreatePerDiemRequestParams} from '@libs/API/parameters'; import {WRITE_COMMANDS} from '@libs/API/types'; @@ -8,6 +6,7 @@ import DateUtils from '@libs/DateUtils'; import {deferOrExecuteWrite} from '@libs/deferredLayoutWrite'; import {getMicroSecondOnyxErrorWithTranslationKey} from '@libs/ErrorUtils'; import {updateIOUOwnerAndTotal} from '@libs/IOUUtils'; +import {formatPhoneNumber} from '@libs/LocalePhoneNumber'; import {validateAmount} from '@libs/MoneyRequestUtils'; import Navigation from '@libs/Navigation/Navigation'; import TransitionTracker from '@libs/Navigation/TransitionTracker'; @@ -244,7 +243,6 @@ type PerDiemExpenseInformation = { // TODO: delegateAccountID will be made required in PR 13 when all callers pass the value (https://github.com/Expensify/App/issues/66425) delegateAccountID?: number | undefined; isTrackIntentUser: boolean | undefined; - formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; }; type PerDiemExpenseInformationParams = { @@ -269,7 +267,6 @@ type PerDiemExpenseInformationParams = { // TODO: delegateAccountID will be made required in PR 13 when all callers pass the value (https://github.com/Expensify/App/issues/66425) delegateAccountID?: number | undefined; isTrackIntentUser: boolean | undefined; - formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; }; type PerDiemExpenseInformationForSelfDM = { @@ -327,7 +324,6 @@ function getPerDiemExpenseInformation(perDiemExpenseInformation: PerDiemExpenseI optimisticTransactionID: uiProvidedOptimisticTransactionID, delegateAccountID, isTrackIntentUser, - formatPhoneNumber, } = perDiemExpenseInformation; const {payeeAccountID = currentUserAccountIDParam, payeeEmail = currentUserEmailParam, participant} = participantParams; const {policy, policyCategories, policyTagList, policyRecentlyUsedCategories, policyRecentlyUsedTags} = policyParams; @@ -936,7 +932,6 @@ function submitPerDiemExpense(submitPerDiemExpenseInformation: PerDiemExpenseInf optimisticTransactionID, delegateAccountID, isTrackIntentUser, - formatPhoneNumber, } = submitPerDiemExpenseInformation; const {currency, comment = '', category, tag, created, customUnit, attendees, isFromGlobalCreate} = transactionParams; @@ -990,7 +985,6 @@ function submitPerDiemExpense(submitPerDiemExpenseInformation: PerDiemExpenseInf optimisticTransactionID, delegateAccountID, isTrackIntentUser, - formatPhoneNumber, }); const activeReportID = isMoneyRequestReport && Navigation.getTopmostReportId() === report?.reportID ? report?.reportID : chatReport.reportID; diff --git a/src/libs/actions/IOU/SendInvoice.ts b/src/libs/actions/IOU/SendInvoice.ts index e66e34d48499..b78e32a89051 100644 --- a/src/libs/actions/IOU/SendInvoice.ts +++ b/src/libs/actions/IOU/SendInvoice.ts @@ -1,11 +1,10 @@ -import type {LocaleContextProps} from '@components/LocaleContextProvider'; - import * as API from '@libs/API'; import type {SendInvoiceParams} from '@libs/API/parameters'; import {WRITE_COMMANDS} from '@libs/API/types'; import DateUtils from '@libs/DateUtils'; import {deferOrExecuteWrite} from '@libs/deferredLayoutWrite'; import {getMicroSecondOnyxErrorWithTranslationKey} from '@libs/ErrorUtils'; +import {formatPhoneNumber} from '@libs/LocalePhoneNumber'; import Log from '@libs/Log'; import {getReportActionHtml, getReportActionText} from '@libs/ReportActionsUtils'; import type {OptimisticChatReport, OptimisticCreatedReportAction, OptimisticIOUReportAction} from '@libs/ReportUtils'; @@ -88,7 +87,6 @@ type SendInvoiceOptions = { senderPolicyTags: OnyxEntry; // TODO: delegateAccountID will be made required in PR 12 when all callers pass the value (https://github.com/Expensify/App/issues/66425) delegateAccountID?: number | undefined; - formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; }; type BuildOnyxDataForInvoiceParams = { @@ -593,7 +591,6 @@ function getSendInvoiceInformation({ policyRecentlyUsedTags, senderPolicyTags, delegateAccountID, - formatPhoneNumber, }: SendInvoiceOptions): SendInvoiceInformation { const {amount = 0, currency = '', created = '', merchant = '', category = '', tag = '', taxCode = '', taxAmount = 0, taxValue, billable, comment, participants} = transaction ?? {}; const trimmedComment = (comment?.comment ?? '').trim(); @@ -743,7 +740,6 @@ function sendInvoice({ isFromGlobalCreate = false, senderPolicyTags, delegateAccountID, - formatPhoneNumber, }: SendInvoiceOptions) { const parsedComment = getParsedComment(transaction?.comment?.comment?.trim() ?? ''); if (transaction?.comment) { @@ -779,7 +775,6 @@ function sendInvoice({ policyRecentlyUsedTags, senderPolicyTags: senderPolicyTags ?? {}, delegateAccountID, - formatPhoneNumber, }); const parameters: SendInvoiceParams = { diff --git a/src/libs/actions/IOU/Split.ts b/src/libs/actions/IOU/Split.ts index c939be28e392..0869d653521e 100644 --- a/src/libs/actions/IOU/Split.ts +++ b/src/libs/actions/IOU/Split.ts @@ -144,7 +144,6 @@ type CreateDistanceRequestInformation = { previousOdometerDraft?: OnyxEntry; delegateAccountID: number | undefined; isTrackIntentUser: boolean | undefined; - formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; }; type CreateSplitsTransactionParams = Omit & { @@ -197,22 +196,6 @@ type StartSplitBilActionParams = { policyRecentlyUsedCurrencies: string[]; participantsPolicyTags: Record; formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; - delegateAccountID: number | undefined; -}; - -type CompleteSplitBillActionParams = { - chatReportID: string; - reportAction: OnyxEntry; - updatedTransaction: OnyxEntry; - sessionAccountID: number; - isASAPSubmitBetaEnabled: boolean; - quickAction: OnyxEntry; - transactionViolations: OnyxCollection; - betas: OnyxEntry; - personalDetails: OnyxEntry; - delegateAccountID: number | undefined; - isTrackIntentUser: boolean | undefined; - sessionEmail?: string; }; type SplitBillActionsParams = { @@ -250,6 +233,20 @@ type SplitBillActionsParams = { formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; }; +type CompleteSplitBillInformation = { + chatReportID: string; + reportAction: OnyxEntry; + updatedTransaction: OnyxEntry; + sessionAccountID: number; + isASAPSubmitBetaEnabled: boolean; + quickAction: OnyxEntry; + transactionViolations: OnyxCollection; + betas: OnyxEntry; + personalDetails: OnyxEntry; + isTrackIntentUser: boolean | undefined; + sessionEmail?: string; +}; + /** * @param amount - always in smallest currency unit * @param existingSplitChatReportID - Either a group DM or a expense chat @@ -511,7 +508,6 @@ function startSplitBill({ shouldHandleNavigation = true, shouldDeferForSearch = false, formatPhoneNumber, - delegateAccountID, }: StartSplitBilActionParams) { const currentUserEmailForIOUSplit = addSMSDomainIfPhoneNumber(currentUserLogin); const participantAccountIDs = participants.map((participant) => Number(participant.accountID)); @@ -553,7 +549,7 @@ function startSplitBill({ transactionID: splitTransaction.transactionID, isOwnPolicyExpenseChat, iouReportID: splitChatReport.reportID, - delegateAccountIDParam: delegateAccountID, + delegateAccountIDParam: undefined, }); splitChatReport.lastReadTime = DateUtils.getDBTime(); @@ -702,7 +698,6 @@ function startSplitBill({ policyRecentlyUsedCurrencies, policyRecentlyUsedTags, participantsPolicyTags, - delegateAccountID, }; if (existingSplitChatReport) { @@ -900,10 +895,9 @@ function completeSplitBill({ transactionViolations, betas, personalDetails, - delegateAccountID, isTrackIntentUser, sessionEmail, -}: CompleteSplitBillActionParams) { +}: CompleteSplitBillInformation) { if (!reportAction) { return; } @@ -1106,14 +1100,14 @@ function completeSplitBill({ participants: [participant], transactionID: oneOnOneTransaction.transactionID, currentUserAccountID: sessionAccountID, - delegateAccountIDParam: delegateAccountID, + delegateAccountIDParam: undefined, }); let oneOnOneReportPreviewAction = getReportPreviewAction(oneOnOneChatReport?.reportID, oneOnOneIOUReport?.reportID); if (oneOnOneReportPreviewAction) { oneOnOneReportPreviewAction = updateReportPreview(oneOnOneIOUReport, oneOnOneReportPreviewAction); } else { - oneOnOneReportPreviewAction = buildOptimisticReportPreview(oneOnOneChatReport, oneOnOneIOUReport, '', oneOnOneTransaction, undefined, undefined, delegateAccountID); + oneOnOneReportPreviewAction = buildOptimisticReportPreview(oneOnOneChatReport, oneOnOneIOUReport, '', oneOnOneTransaction, undefined, undefined, undefined); } const hasViolations = hasViolationsReportUtils(oneOnOneIOUReport.reportID, transactionViolations, sessionAccountID, sessionEmail ?? ''); @@ -1149,7 +1143,7 @@ function completeSplitBill({ }, quickAction, personalDetails, - delegateAccountID, + delegateAccountID: undefined, isTrackIntentUser, }); @@ -1969,7 +1963,6 @@ function createDistanceRequest(distanceRequestInformation: CreateDistanceRequest previousOdometerDraft, delegateAccountID, isTrackIntentUser, - formatPhoneNumber, } = distanceRequestInformation; const {policy, policyCategories, policyTagList, policyRecentlyUsedCategories, policyRecentlyUsedTags} = policyParams; const parsedComment = getParsedComment(transactionParams.comment); @@ -2062,7 +2055,6 @@ function createDistanceRequest(distanceRequestInformation: CreateDistanceRequest participantsPolicyTags: buildParticipantsPolicyTags(participants), delegateAccountID, isTrackIntentUser, - formatPhoneNumber, }); onyxData = splitOnyxData; @@ -2156,7 +2148,6 @@ function createDistanceRequest(distanceRequestInformation: CreateDistanceRequest optimisticReportPreviewActionID, delegateAccountID, isTrackIntentUser, - formatPhoneNumber, }); onyxData = moneyRequestOnyxData; diff --git a/src/libs/actions/IOU/SplitTransactionUpdate.ts b/src/libs/actions/IOU/SplitTransactionUpdate.ts index 40271b573d0f..f246aaf587b1 100644 --- a/src/libs/actions/IOU/SplitTransactionUpdate.ts +++ b/src/libs/actions/IOU/SplitTransactionUpdate.ts @@ -108,7 +108,6 @@ type UpdateSplitTransactionsParams = { transactionReport: OnyxEntry; expenseReport: OnyxEntry; isOffline: boolean; - delegateAccountID: number | undefined; isTrackIntentUser: boolean | undefined; formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; }; @@ -139,7 +138,6 @@ function updateSplitTransactions({ transactionReport, expenseReport: expenseReportFromParams, isOffline, - delegateAccountID, isTrackIntentUser, formatPhoneNumber, }: UpdateSplitTransactionsParams) { @@ -597,7 +595,7 @@ function updateSplitTransactions({ policyRecentlyUsedCurrencies, betas, personalDetails, - delegateAccountID, + delegateAccountID: undefined, isTrackIntentUser, } as MoneyRequestInformationParams; @@ -711,7 +709,7 @@ function updateSplitTransactions({ policyRecentlyUsedCurrencies, betas, personalDetails, - delegateAccountID, + delegateAccountID: undefined, isTrackIntentUser, formatPhoneNumber, }); @@ -808,7 +806,7 @@ function updateSplitTransactions({ isSplitTransaction: true, isSelfDMSplit, isOffline, - delegateAccountID, + delegateAccountID: undefined, isTrackIntentUser, }); if (currentSplit) { @@ -889,7 +887,7 @@ function updateSplitTransactions({ actorAccountID: commentAction.actorAccountID, reportID: transactionThreadReportID, reportActionID: newReportActionID, - delegateAccountIDParam: delegateAccountID, + delegateAccountIDParam: undefined, }); const reportActionComment = { ...reportComment.reportAction, diff --git a/src/libs/actions/Task.ts b/src/libs/actions/Task.ts index 0dda3be0c64e..f842b96831f0 100644 --- a/src/libs/actions/Task.ts +++ b/src/libs/actions/Task.ts @@ -7,6 +7,7 @@ import type {CancelTaskParams, CompleteTaskParams, CreateTaskParams, EditTaskAss import {WRITE_COMMANDS} from '@libs/API/types'; import DateUtils from '@libs/DateUtils'; import * as ErrorUtils from '@libs/ErrorUtils'; +import * as LocalePhoneNumber from '@libs/LocalePhoneNumber'; import createDynamicRoute from '@libs/Navigation/helpers/dynamicRoutesUtils/createDynamicRoute'; import Navigation from '@libs/Navigation/Navigation'; import {getDBTimeWithSkew} from '@libs/NetworkState'; @@ -1096,12 +1097,7 @@ function startOutCreateTaskQuickAction(currentUserAccountID: number, reportID: s /** * Get the assignee data */ -function getAssignee( - assigneeAccountID: number | undefined, - personalDetails: OnyxEntry, - translate: LocalizedTranslate, - formatPhoneNumber: LocaleContextProps['formatPhoneNumber'], -): Assignee | undefined { +function getAssignee(assigneeAccountID: number | undefined, personalDetails: OnyxEntry, translate: LocalizedTranslate): Assignee | undefined { if (!assigneeAccountID) { return; } @@ -1118,7 +1114,7 @@ function getAssignee( return { icons: ReportUtils.getIconsForParticipants([details.accountID], personalDetails), - displayName: formatPhoneNumber(PersonalDetailsUtils.temporaryGetDisplayNameOrDefault({passedPersonalDetails: details, translate})), + displayName: LocalePhoneNumber.formatPhoneNumber(PersonalDetailsUtils.temporaryGetDisplayNameOrDefault({passedPersonalDetails: details, translate})), subtitle: details.login ?? '', }; } @@ -1133,7 +1129,6 @@ function getShareDestination( policy: OnyxEntry, conciergeReportID: string | undefined, translate: LocalizedTranslate, - formatPhoneNumber: LocaleContextProps['formatPhoneNumber'], reportAttributes?: OnyxTypes.ReportAttributesDerivedValue['reports'], ): ShareDestination { const isOneOnOneChat = ReportUtils.isOneOnOneChat(report); @@ -1145,7 +1140,7 @@ function getShareDestination( OptionsListUtils.getPersonalDetailsForAccountIDs(participants, personalDetails), isMultipleParticipant, localeCompare, - formatPhoneNumber, + LocalePhoneNumber.formatPhoneNumber, ); let subtitle = ''; @@ -1154,12 +1149,12 @@ function getShareDestination( const displayName = personalDetails?.[participantAccountID]?.displayName ?? ''; const login = personalDetails?.[participantAccountID]?.login ?? ''; - subtitle = formatPhoneNumber(login || displayName); + subtitle = LocalePhoneNumber.formatPhoneNumber(login || displayName); } else { subtitle = ReportUtils.getChatRoomSubtitle(report, policy, conciergeReportID, translate) ?? ''; } return { - icons: ReportUtils.getIcons(report, formatPhoneNumber, translate, personalDetails, FallbackAvatar), + icons: ReportUtils.getIcons(report, LocalePhoneNumber.formatPhoneNumber, translate, personalDetails, FallbackAvatar), displayName: getReportName(report, reportAttributes), subtitle, displayNamesWithTooltips, diff --git a/src/pages/iou/request/step/IOURequestStepCompanyInfo.tsx b/src/pages/iou/request/step/IOURequestStepCompanyInfo.tsx index 4d63772a322b..42763de1717e 100644 --- a/src/pages/iou/request/step/IOURequestStepCompanyInfo.tsx +++ b/src/pages/iou/request/step/IOURequestStepCompanyInfo.tsx @@ -48,7 +48,7 @@ function IOURequestStepCompanyInfo({route, report, transaction}: IOURequestStepC const {backTo, reportID} = route.params; const styles = useThemeStyles(); - const {translate, formatPhoneNumber} = useLocalize(); + const {translate} = useLocalize(); const {convertToDisplayString} = useCurrencyListActions(); const {inputCallbackRef} = useAutoFocusInput(); const currentUserPersonalDetails = useCurrentUserPersonalDetails(); @@ -120,7 +120,6 @@ function IOURequestStepCompanyInfo({route, report, transaction}: IOURequestStepC policyRecentlyUsedTags, isFromGlobalCreate, senderPolicyTags: policyTags ?? {}, - formatPhoneNumber, }); cleanupAndNavigateAfterExpenseCreate({ report: undefined, diff --git a/src/pages/tasks/DynamicNewTaskPage.tsx b/src/pages/tasks/DynamicNewTaskPage.tsx index 3b2f6ca80c4a..a4073f6ccd84 100644 --- a/src/pages/tasks/DynamicNewTaskPage.tsx +++ b/src/pages/tasks/DynamicNewTaskPage.tsx @@ -47,16 +47,14 @@ function DynamicNewTaskPage() { }); const styles = useThemeStyles(); const {translate, formatPhoneNumber, localeCompare} = useLocalize(); - const assignee = getAssignee(task?.assigneeAccountID ?? CONST.DEFAULT_NUMBER_ID, personalDetails, translate, formatPhoneNumber); + const assignee = getAssignee(task?.assigneeAccountID ?? CONST.DEFAULT_NUMBER_ID, personalDetails, translate); const assigneeTooltipDetails = getDisplayNamesWithTooltips( getPersonalDetailsForAccountIDs(task?.assigneeAccountID ? [task.assigneeAccountID] : [], personalDetails), false, localeCompare, formatPhoneNumber, ); - const shareDestination = task?.shareDestination - ? getShareDestination(parentReport, personalDetails, localeCompare, policy, conciergeReportID, translate, formatPhoneNumber, reportAttributes) - : undefined; + const shareDestination = task?.shareDestination ? getShareDestination(parentReport, personalDetails, localeCompare, policy, conciergeReportID, translate, reportAttributes) : undefined; const ancestors = useAncestors(parentReport); const taskKey = `${task?.assignee}|${task?.assigneeAccountID}|${task?.description}|${task?.parentReportID}|${task?.shareDestination}|${task?.title}`; const [error, setError] = useState<{message: string; taskKey: string}>({ diff --git a/tests/actions/IOU/GetMoneyRequestInformationTest.ts b/tests/actions/IOU/GetMoneyRequestInformationTest.ts index 802608cef452..dd76fa00547b 100644 --- a/tests/actions/IOU/GetMoneyRequestInformationTest.ts +++ b/tests/actions/IOU/GetMoneyRequestInformationTest.ts @@ -70,7 +70,6 @@ const baseParams = { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, } as const; describe('getMoneyRequestInformation', () => { diff --git a/tests/actions/IOU/PerDiemTest.ts b/tests/actions/IOU/PerDiemTest.ts index f80cee6e468d..7a827cb6d056 100644 --- a/tests/actions/IOU/PerDiemTest.ts +++ b/tests/actions/IOU/PerDiemTest.ts @@ -327,7 +327,6 @@ describe('PerDiem', () => { betas: [CONST.BETAS.ALL], personalDetails: {[mockParticipantParams.payeeAccountID]: {accountID: mockParticipantParams.payeeAccountID, login: 'payee@example.com'}}, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, }); expect(result.onyxData).toBeDefined(); @@ -419,7 +418,6 @@ describe('PerDiem', () => { betas: [CONST.BETAS.ALL], personalDetails: {[mockParticipant.accountID]: {accountID: mockParticipant.accountID, login: 'existing@example.com'}}, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, }); // Then: Verify the result structure and key values @@ -555,7 +553,6 @@ describe('PerDiem', () => { betas: [CONST.BETAS.ALL], personalDetails: {[mockParticipant.accountID]: {accountID: mockParticipant.accountID, login: 'existing@example.com'}}, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, }); // Then: Verify the result uses existing chat report @@ -645,7 +642,6 @@ describe('PerDiem', () => { betas: [CONST.BETAS.ALL], personalDetails: {[mockParticipant.accountID]: {accountID: mockParticipant.accountID, login: 'existing@example.com'}}, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, }); // Then: Verify policy expense chat handling @@ -722,7 +718,6 @@ describe('PerDiem', () => { betas: [CONST.BETAS.ALL], personalDetails: {[RORY_ACCOUNT_ID]: {accountID: RORY_ACCOUNT_ID, login: RORY_EMAIL}}, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -792,7 +787,6 @@ describe('PerDiem', () => { personalDetails: {[RORY_ACCOUNT_ID]: {accountID: RORY_ACCOUNT_ID, login: RORY_EMAIL}}, optimisticTransactionID, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -867,7 +861,6 @@ describe('PerDiem', () => { betas: [CONST.BETAS.ALL], personalDetails: personalDetailsList, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, }); // Then the result should be valid (personalDetails is correctly passed through the chain) @@ -933,7 +926,6 @@ describe('PerDiem', () => { betas: [CONST.BETAS.ALL], personalDetails: personalDetailsList, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); diff --git a/tests/actions/IOUTest/SendInvoiceTest.ts b/tests/actions/IOUTest/SendInvoiceTest.ts index 131dbe9de639..8683ed262b2b 100644 --- a/tests/actions/IOUTest/SendInvoiceTest.ts +++ b/tests/actions/IOUTest/SendInvoiceTest.ts @@ -624,7 +624,6 @@ describe('actions/SendInvoice', () => { companyName, companyWebsite, senderPolicyTags: undefined, - formatPhoneNumber: (n: string) => n, }); // Then a new invoice chat is created instead of incorrectly using the invoice chat which has been converted from individual to business @@ -653,7 +652,6 @@ describe('actions/SendInvoice', () => { transaction, policyRecentlyUsedCurrencies: initialCurrencies, senderPolicyTags: undefined, - formatPhoneNumber: (n: string) => n, }); mockFetch?.fail?.(); @@ -694,7 +692,6 @@ describe('actions/SendInvoice', () => { policyRecentlyUsedCurrencies: [], policyRecentlyUsedCategories, senderPolicyTags: undefined, - formatPhoneNumber: (n: string) => n, }); // Then onyxData should be passed to API.write @@ -736,7 +733,6 @@ describe('actions/SendInvoice', () => { orderWeight: 0, }, }, - formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -772,7 +768,6 @@ describe('actions/SendInvoice', () => { policyRecentlyUsedCurrencies: [], invoiceChatReportID: preGeneratedReportID, senderPolicyTags: undefined, - formatPhoneNumber: (n: string) => n, }); expect(writeSpy).toHaveBeenCalledWith( From 4b95e74cf2f3dbc7f035c158681899dce154e311 Mon Sep 17 00:00:00 2001 From: Maruf Sharifi Date: Thu, 16 Jul 2026 18:00:32 +0300 Subject: [PATCH 08/12] Restore delegateAccountID in Split types and fix lint errors --- src/libs/actions/IOU/Split.ts | 46 +++++++++++-------- .../actions/IOU/SplitTransactionUpdate.ts | 11 +++-- 2 files changed, 32 insertions(+), 25 deletions(-) diff --git a/src/libs/actions/IOU/Split.ts b/src/libs/actions/IOU/Split.ts index 0869d653521e..75cc9588f2c6 100644 --- a/src/libs/actions/IOU/Split.ts +++ b/src/libs/actions/IOU/Split.ts @@ -9,6 +9,7 @@ import DateUtils from '@libs/DateUtils'; import {deferOrExecuteWrite} from '@libs/deferredLayoutWrite'; import {getMicroSecondOnyxErrorWithTranslationKey} from '@libs/ErrorUtils'; import {calculateAmount as calculateIOUAmount, updateIOUOwnerAndTotal} from '@libs/IOUUtils'; +import {formatPhoneNumber} from '@libs/LocalePhoneNumber'; import * as Localize from '@libs/Localize'; import Navigation from '@libs/Navigation/Navigation'; import TransitionTracker from '@libs/Navigation/TransitionTracker'; @@ -195,6 +196,22 @@ type StartSplitBilActionParams = { quickAction: OnyxEntry; policyRecentlyUsedCurrencies: string[]; participantsPolicyTags: Record; + delegateAccountID: number | undefined; +}; + +type CompleteSplitBillActionParams = { + chatReportID: string; + reportAction: OnyxEntry; + updatedTransaction: OnyxEntry; + sessionAccountID: number; + isASAPSubmitBetaEnabled: boolean; + quickAction: OnyxEntry; + transactionViolations: OnyxCollection; + betas: OnyxEntry; + personalDetails: OnyxEntry; + delegateAccountID: number | undefined; + isTrackIntentUser: boolean | undefined; + sessionEmail?: string; formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; }; @@ -233,20 +250,6 @@ type SplitBillActionsParams = { formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; }; -type CompleteSplitBillInformation = { - chatReportID: string; - reportAction: OnyxEntry; - updatedTransaction: OnyxEntry; - sessionAccountID: number; - isASAPSubmitBetaEnabled: boolean; - quickAction: OnyxEntry; - transactionViolations: OnyxCollection; - betas: OnyxEntry; - personalDetails: OnyxEntry; - isTrackIntentUser: boolean | undefined; - sessionEmail?: string; -}; - /** * @param amount - always in smallest currency unit * @param existingSplitChatReportID - Either a group DM or a expense chat @@ -507,7 +510,7 @@ function startSplitBill({ participantsPolicyTags, shouldHandleNavigation = true, shouldDeferForSearch = false, - formatPhoneNumber, + delegateAccountID, }: StartSplitBilActionParams) { const currentUserEmailForIOUSplit = addSMSDomainIfPhoneNumber(currentUserLogin); const participantAccountIDs = participants.map((participant) => Number(participant.accountID)); @@ -549,7 +552,7 @@ function startSplitBill({ transactionID: splitTransaction.transactionID, isOwnPolicyExpenseChat, iouReportID: splitChatReport.reportID, - delegateAccountIDParam: undefined, + delegateAccountIDParam: delegateAccountID, }); splitChatReport.lastReadTime = DateUtils.getDBTime(); @@ -698,6 +701,7 @@ function startSplitBill({ policyRecentlyUsedCurrencies, policyRecentlyUsedTags, participantsPolicyTags, + delegateAccountID, }; if (existingSplitChatReport) { @@ -895,9 +899,10 @@ function completeSplitBill({ transactionViolations, betas, personalDetails, + delegateAccountID, isTrackIntentUser, sessionEmail, -}: CompleteSplitBillInformation) { +}: CompleteSplitBillActionParams) { if (!reportAction) { return; } @@ -1100,14 +1105,14 @@ function completeSplitBill({ participants: [participant], transactionID: oneOnOneTransaction.transactionID, currentUserAccountID: sessionAccountID, - delegateAccountIDParam: undefined, + delegateAccountIDParam: delegateAccountID, }); let oneOnOneReportPreviewAction = getReportPreviewAction(oneOnOneChatReport?.reportID, oneOnOneIOUReport?.reportID); if (oneOnOneReportPreviewAction) { oneOnOneReportPreviewAction = updateReportPreview(oneOnOneIOUReport, oneOnOneReportPreviewAction); } else { - oneOnOneReportPreviewAction = buildOptimisticReportPreview(oneOnOneChatReport, oneOnOneIOUReport, '', oneOnOneTransaction, undefined, undefined, undefined); + oneOnOneReportPreviewAction = buildOptimisticReportPreview(oneOnOneChatReport, oneOnOneIOUReport, '', oneOnOneTransaction, undefined, undefined, delegateAccountID); } const hasViolations = hasViolationsReportUtils(oneOnOneIOUReport.reportID, transactionViolations, sessionAccountID, sessionEmail ?? ''); @@ -1143,7 +1148,7 @@ function completeSplitBill({ }, quickAction, personalDetails, - delegateAccountID: undefined, + delegateAccountID, isTrackIntentUser, }); @@ -2055,6 +2060,7 @@ function createDistanceRequest(distanceRequestInformation: CreateDistanceRequest participantsPolicyTags: buildParticipantsPolicyTags(participants), delegateAccountID, isTrackIntentUser, + formatPhoneNumber, }); onyxData = splitOnyxData; diff --git a/src/libs/actions/IOU/SplitTransactionUpdate.ts b/src/libs/actions/IOU/SplitTransactionUpdate.ts index f246aaf587b1..2ec5ba1d504e 100644 --- a/src/libs/actions/IOU/SplitTransactionUpdate.ts +++ b/src/libs/actions/IOU/SplitTransactionUpdate.ts @@ -108,6 +108,7 @@ type UpdateSplitTransactionsParams = { transactionReport: OnyxEntry; expenseReport: OnyxEntry; isOffline: boolean; + delegateAccountID: number | undefined; isTrackIntentUser: boolean | undefined; formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; }; @@ -138,6 +139,7 @@ function updateSplitTransactions({ transactionReport, expenseReport: expenseReportFromParams, isOffline, + delegateAccountID, isTrackIntentUser, formatPhoneNumber, }: UpdateSplitTransactionsParams) { @@ -595,7 +597,7 @@ function updateSplitTransactions({ policyRecentlyUsedCurrencies, betas, personalDetails, - delegateAccountID: undefined, + delegateAccountID, isTrackIntentUser, } as MoneyRequestInformationParams; @@ -709,9 +711,8 @@ function updateSplitTransactions({ policyRecentlyUsedCurrencies, betas, personalDetails, - delegateAccountID: undefined, + delegateAccountID, isTrackIntentUser, - formatPhoneNumber, }); let updateMoneyRequestParamsOnyxData: OnyxData = {}; @@ -806,7 +807,7 @@ function updateSplitTransactions({ isSplitTransaction: true, isSelfDMSplit, isOffline, - delegateAccountID: undefined, + delegateAccountID, isTrackIntentUser, }); if (currentSplit) { @@ -887,7 +888,7 @@ function updateSplitTransactions({ actorAccountID: commentAction.actorAccountID, reportID: transactionThreadReportID, reportActionID: newReportActionID, - delegateAccountIDParam: undefined, + delegateAccountIDParam: delegateAccountID, }); const reportActionComment = { ...reportComment.reportAction, From 263baee07681cd2e520816c0cea45cd443af36b3 Mon Sep 17 00:00:00 2001 From: Maruf Sharifi Date: Thu, 16 Jul 2026 23:01:25 +0300 Subject: [PATCH 09/12] Pass phone formatter through IOU split flows --- src/libs/actions/IOU/Duplicate.ts | 2 + src/libs/actions/IOU/Split.ts | 17 ++--- .../actions/IOU/SplitTransactionUpdate.ts | 3 - src/pages/Travel/TravelLegalNamePage.tsx | 3 +- ...andleMoneyRequestStepDistanceNavigation.ts | 2 + .../components/ScanSkipConfirmation.tsx | 3 +- .../step/confirmation/useExpenseSubmission.ts | 4 +- tests/actions/IOU/SplitReportTotalsTest.ts | 4 +- tests/actions/IOUTest/SplitSelfDMTest.ts | 6 -- tests/actions/IOUTest/SplitTest.ts | 70 ++++--------------- 10 files changed, 33 insertions(+), 81 deletions(-) diff --git a/src/libs/actions/IOU/Duplicate.ts b/src/libs/actions/IOU/Duplicate.ts index 16ec5d43afc5..86cf1714ca3a 100644 --- a/src/libs/actions/IOU/Duplicate.ts +++ b/src/libs/actions/IOU/Duplicate.ts @@ -7,6 +7,7 @@ import {WRITE_COMMANDS} from '@libs/API/types'; import DateUtils from '@libs/DateUtils'; import {getMicroSecondOnyxErrorWithTranslationKey} from '@libs/ErrorUtils'; import {getExistingTransactionID} from '@libs/IOUUtils'; +import {formatPhoneNumber} from '@libs/LocalePhoneNumber'; import * as NumberUtils from '@libs/NumberUtils'; import Parser from '@libs/Parser'; import {isInstantSubmitEnabled, isPolicyAccessible, isSubmitAndClose} from '@libs/PolicyUtils'; @@ -701,6 +702,7 @@ function createExpenseByType({ customUnitPolicyID, personalDetails, recentWaypoints, + formatPhoneNumber, }; return createDistanceRequest(distanceParams); } diff --git a/src/libs/actions/IOU/Split.ts b/src/libs/actions/IOU/Split.ts index 75cc9588f2c6..ef26a8fd3d82 100644 --- a/src/libs/actions/IOU/Split.ts +++ b/src/libs/actions/IOU/Split.ts @@ -145,6 +145,7 @@ type CreateDistanceRequestInformation = { previousOdometerDraft?: OnyxEntry; delegateAccountID: number | undefined; isTrackIntentUser: boolean | undefined; + formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; }; type CreateSplitsTransactionParams = Omit & { @@ -212,7 +213,6 @@ type CompleteSplitBillActionParams = { delegateAccountID: number | undefined; isTrackIntentUser: boolean | undefined; sessionEmail?: string; - formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; }; type SplitBillActionsParams = { @@ -285,7 +285,7 @@ function splitBill({ shouldDeferForSearch = false, delegateAccountID, isTrackIntentUser, - formatPhoneNumber, + formatPhoneNumber: formatPhoneNumberParam, }: SplitBillActionsParams) { const parsedComment = getParsedComment(comment); const {splitData, splits, onyxData} = createSplitsAndOnyxData({ @@ -321,7 +321,7 @@ function splitBill({ participantsPolicyTags: buildParticipantsPolicyTags(participants), delegateAccountID, isTrackIntentUser, - formatPhoneNumber, + formatPhoneNumber: formatPhoneNumberParam, }); const parameters: SplitBillParams = { @@ -401,7 +401,7 @@ function splitBillAndOpenReport({ shouldDeferForSearch = false, delegateAccountID, isTrackIntentUser, - formatPhoneNumber, + formatPhoneNumber: formatPhoneNumberParam, }: SplitBillActionsParams) { const parsedComment = getParsedComment(comment); const {splitData, splits, onyxData} = createSplitsAndOnyxData({ @@ -437,7 +437,7 @@ function splitBillAndOpenReport({ participantsPolicyTags: buildParticipantsPolicyTags(participants), delegateAccountID, isTrackIntentUser, - formatPhoneNumber, + formatPhoneNumber: formatPhoneNumberParam, }); const parameters: SplitBillParams = { @@ -1433,7 +1433,7 @@ function createSplitsAndOnyxData({ participantsPolicyTags, delegateAccountID, isTrackIntentUser, - formatPhoneNumber, + formatPhoneNumber: formatPhoneNumberParam, }: CreateSplitsAndOnyxDataParams): SplitsAndOnyxData { const currentUserEmailForIOUSplit = addSMSDomainIfPhoneNumber(currentUserLogin); const participantAccountIDs = participants.map((participant) => Number(participant.accountID)); @@ -1816,7 +1816,7 @@ function createSplitsAndOnyxData({ accountID, // Disabling this line since participant.displayName can be an empty string // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - displayName: formatPhoneNumber(participant.displayName || email), + displayName: formatPhoneNumberParam(participant.displayName || email), login: participant.login, isOptimisticPersonalDetail: true, }, @@ -1968,6 +1968,7 @@ function createDistanceRequest(distanceRequestInformation: CreateDistanceRequest previousOdometerDraft, delegateAccountID, isTrackIntentUser, + formatPhoneNumber: formatPhoneNumberParam, } = distanceRequestInformation; const {policy, policyCategories, policyTagList, policyRecentlyUsedCategories, policyRecentlyUsedTags} = policyParams; const parsedComment = getParsedComment(transactionParams.comment); @@ -2060,7 +2061,7 @@ function createDistanceRequest(distanceRequestInformation: CreateDistanceRequest participantsPolicyTags: buildParticipantsPolicyTags(participants), delegateAccountID, isTrackIntentUser, - formatPhoneNumber, + formatPhoneNumber: formatPhoneNumberParam, }); onyxData = splitOnyxData; diff --git a/src/libs/actions/IOU/SplitTransactionUpdate.ts b/src/libs/actions/IOU/SplitTransactionUpdate.ts index 2ec5ba1d504e..049d7906a9cd 100644 --- a/src/libs/actions/IOU/SplitTransactionUpdate.ts +++ b/src/libs/actions/IOU/SplitTransactionUpdate.ts @@ -1,4 +1,3 @@ -import type {LocaleContextProps} from '@components/LocaleContextProvider'; import type {SearchActionsContextValue, SearchStateContextValue} from '@components/Search/types'; import {write as apiWrite} from '@libs/API'; @@ -110,7 +109,6 @@ type UpdateSplitTransactionsParams = { isOffline: boolean; delegateAccountID: number | undefined; isTrackIntentUser: boolean | undefined; - formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; }; function updateSplitTransactions({ @@ -141,7 +139,6 @@ 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 diff --git a/src/pages/Travel/TravelLegalNamePage.tsx b/src/pages/Travel/TravelLegalNamePage.tsx index cd0bff196fa7..09a8375148eb 100644 --- a/src/pages/Travel/TravelLegalNamePage.tsx +++ b/src/pages/Travel/TravelLegalNamePage.tsx @@ -8,6 +8,7 @@ import useThemeStyles from '@hooks/useThemeStyles'; import {clearDraftValues} from '@libs/actions/FormActions'; import {updateLegalName} from '@libs/actions/PersonalDetails'; +import {formatPhoneNumber} from '@libs/LocalePhoneNumber'; import Navigation from '@libs/Navigation/Navigation'; import BaseLegalNamePage, {validateLegalName} from '@pages/settings/Profile/PersonalDetails/BaseLegalNamePage'; @@ -18,7 +19,7 @@ import INPUT_IDS from '@src/types/form/PersonalDetailsForm'; import React, {useEffect} from 'react'; function TravelLegalNamePage() { - const {translate, formatPhoneNumber} = useLocalize(); + const {translate} = useLocalize(); const styles = useThemeStyles(); const currentUserPersonalDetails = useCurrentUserPersonalDetails(); const [privatePersonalDetails] = useOnyx(ONYXKEYS.PRIVATE_PERSONAL_DETAILS); diff --git a/src/pages/iou/request/step/IOURequestStepDistance/handleMoneyRequestStepDistanceNavigation.ts b/src/pages/iou/request/step/IOURequestStepDistance/handleMoneyRequestStepDistanceNavigation.ts index 4244211a0834..c87393ebb1d4 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance/handleMoneyRequestStepDistanceNavigation.ts +++ b/src/pages/iou/request/step/IOURequestStepDistance/handleMoneyRequestStepDistanceNavigation.ts @@ -12,6 +12,7 @@ import {getCurrencySymbol} from '@libs/CurrencyUtils'; import DistanceRequestUtils from '@libs/DistanceRequestUtils'; import {calculateDefaultReimbursable, getExistingTransactionID, navigateToConfirmationPage, navigateToParticipantPage} from '@libs/IOUUtils'; import {toLocaleDigit} from '@libs/LocaleDigitUtils'; +import {formatPhoneNumber} from '@libs/LocalePhoneNumber'; import cleanupAfterSkipConfirmSubmit from '@libs/Navigation/helpers/cleanupAfterSkipConfirmSubmit'; import {submitWithDismissFirst} from '@libs/Navigation/helpers/submitWithDismissFirst'; import Navigation from '@libs/Navigation/Navigation'; @@ -404,6 +405,7 @@ function handleMoneyRequestStepDistanceNavigation({ }, isTrackIntentUser, delegateAccountID, + formatPhoneNumber, }); cleanupAfterSkipConfirmSubmit(overrides.shouldHandleNavigation, { report, diff --git a/src/pages/iou/request/step/IOURequestStepScan/components/ScanSkipConfirmation.tsx b/src/pages/iou/request/step/IOURequestStepScan/components/ScanSkipConfirmation.tsx index 7a2aa72710f0..a3e90a130f0e 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/components/ScanSkipConfirmation.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/components/ScanSkipConfirmation.tsx @@ -108,7 +108,7 @@ function ScanSkipConfirmation({report, action, iouType, reportID, transactionID, const [transactions] = useOptimisticDraftTransactions(transaction); const {isMultiScanEnabled} = useMultiScanState(); - const {translate, formatPhoneNumber} = useLocalize(); + const {translate} = useLocalize(); const {disableMultiScan} = useMultiScanActions(); const {setIsLoaderVisible} = useFullScreenLoaderActions(); const [startLocationPermissionFlow, setStartLocationPermissionFlow] = useState(false); @@ -235,7 +235,6 @@ function ScanSkipConfirmation({report, action, iouType, reportID, transactionID, ...splitBaseParams, shouldHandleNavigation: overrides.shouldHandleNavigation, shouldDeferForSearch: false, - formatPhoneNumber, }); cleanupAfterSkipConfirmSubmit(overrides.shouldHandleNavigation, { report, diff --git a/src/pages/iou/request/step/confirmation/useExpenseSubmission.ts b/src/pages/iou/request/step/confirmation/useExpenseSubmission.ts index 032fb6e36fdd..fc0f0a4d4e59 100644 --- a/src/pages/iou/request/step/confirmation/useExpenseSubmission.ts +++ b/src/pages/iou/request/step/confirmation/useExpenseSubmission.ts @@ -612,7 +612,6 @@ function useExpenseSubmission(params: UseExpenseSubmissionParams) { personalDetails, optimisticChatReportID, isTrackIntentUser, - formatPhoneNumber, }); const targetReportID = backToReport ?? activeReportID; // When backToReport exists we are creating the expense from chat, not the expense report, so no pending transaction registration needed. @@ -798,6 +797,7 @@ function useExpenseSubmission(params: UseExpenseSubmissionParams) { previousOdometerDraft: odometerDraft, isTrackIntentUser, delegateAccountID, + formatPhoneNumber, }); const isExpenseReport = isMoneyRequestReportReportUtils(report); @@ -875,7 +875,6 @@ function useExpenseSubmission(params: UseExpenseSubmissionParams) { participantsPolicyTags, shouldHandleNavigation, shouldDeferForSearch: shouldDeferSplitForSearch, - formatPhoneNumber, delegateAccountID, }); } @@ -984,7 +983,6 @@ function useExpenseSubmission(params: UseExpenseSubmissionParams) { isFromGlobalCreate: getIsFromGlobalCreate(transaction), policyRecentlyUsedTags, senderPolicyTags: senderWorkspacePolicyTags ?? {}, - formatPhoneNumber, }); if (shouldHandleNavigation) { cleanupAndNavigateAfterExpenseCreate({ diff --git a/tests/actions/IOU/SplitReportTotalsTest.ts b/tests/actions/IOU/SplitReportTotalsTest.ts index 5f15f145183d..c10f9aa8e03f 100644 --- a/tests/actions/IOU/SplitReportTotalsTest.ts +++ b/tests/actions/IOU/SplitReportTotalsTest.ts @@ -27,6 +27,7 @@ import {getGlobalFetchMock} from '../../utils/TestHelper'; import waitForBatchedUpdates from '../../utils/waitForBatchedUpdates'; const topMostReportID = '23423423'; +const mockFormatPhoneNumber = (phoneNumber: string) => phoneNumber; jest.mock('@src/libs/Navigation/Navigation', () => ({ navigate: jest.fn(), dismissModal: jest.fn(), @@ -507,7 +508,7 @@ describe('actions/IOU', () => { participantsPolicyTags: overrides.participantsPolicyTags ?? {}, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, + formatPhoneNumber: mockFormatPhoneNumber, }); it('returns valid splitData with chatReportID, transactionID, and reportActionID', () => { @@ -773,7 +774,6 @@ describe('actions/IOU', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, ...overrides, }; } diff --git a/tests/actions/IOUTest/SplitSelfDMTest.ts b/tests/actions/IOUTest/SplitSelfDMTest.ts index 04f2f0780c17..1d727cdd6e32 100644 --- a/tests/actions/IOUTest/SplitSelfDMTest.ts +++ b/tests/actions/IOUTest/SplitSelfDMTest.ts @@ -221,7 +221,6 @@ describe('updateSplitTransactionsFromSplitExpensesFlow - selfDM', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -312,7 +311,6 @@ describe('updateSplitTransactionsFromSplitExpensesFlow - selfDM', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -424,7 +422,6 @@ describe('updateSplitTransactionsFromSplitExpensesFlow - selfDM', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -521,7 +518,6 @@ describe('updateSplitTransactionsFromSplitExpensesFlow - selfDM', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -584,7 +580,6 @@ describe('updateSplitTransactionsFromSplitExpensesFlow - selfDM', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -678,7 +673,6 @@ describe('updateSplitTransactionsFromSplitExpensesFlow - selfDM', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); diff --git a/tests/actions/IOUTest/SplitTest.ts b/tests/actions/IOUTest/SplitTest.ts index a7aa331cdfde..bcb78ba20785 100644 --- a/tests/actions/IOUTest/SplitTest.ts +++ b/tests/actions/IOUTest/SplitTest.ts @@ -110,6 +110,7 @@ jest.mock('@libs/deferredLayoutWrite', () => ({ jest.mock('@hooks/useCardFeedsForDisplay', () => jest.fn(() => ({defaultCardFeed: null, cardFeedsByPolicy: {}}))); const unapprovedCashHash = 71801560; +const mockFormatPhoneNumber = (phoneNumber: string) => phoneNumber; jest.mock('@src/libs/SearchQueryUtils', () => { const actual = jest.requireActual('@src/libs/SearchQueryUtils'); // eslint-disable-next-line @typescript-eslint/no-unsafe-return @@ -414,7 +415,7 @@ describe('split expense', () => { personalDetails: mockPersonalDetails, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, + formatPhoneNumber: mockFormatPhoneNumber, }, ); return waitForBatchedUpdates(); @@ -752,7 +753,7 @@ describe('split expense', () => { personalDetails: mockPersonalDetails, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, + formatPhoneNumber: mockFormatPhoneNumber, }); await waitForBatchedUpdates(); @@ -804,7 +805,7 @@ describe('split expense', () => { personalDetails: mockPersonalDetails, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, + formatPhoneNumber: mockFormatPhoneNumber, }); await waitForBatchedUpdates(); @@ -830,7 +831,7 @@ describe('split expense', () => { personalDetails: mockPersonalDetails, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, + formatPhoneNumber: mockFormatPhoneNumber, }); await waitForBatchedUpdates(); @@ -863,7 +864,7 @@ describe('split expense', () => { personalDetails: mockPersonalDetails, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, + formatPhoneNumber: mockFormatPhoneNumber, }); await waitForBatchedUpdates(); @@ -901,7 +902,7 @@ describe('split expense', () => { personalDetails: mockPersonalDetails, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, + formatPhoneNumber: mockFormatPhoneNumber, }); await waitForBatchedUpdates(); @@ -925,7 +926,7 @@ describe('split expense', () => { personalDetails: mockPersonalDetails, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, + formatPhoneNumber: mockFormatPhoneNumber, }); await waitForBatchedUpdates(); @@ -993,7 +994,7 @@ describe('split expense', () => { personalDetails: mockPersonalDetails, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, + formatPhoneNumber: mockFormatPhoneNumber, }); await waitForBatchedUpdates(); @@ -1046,7 +1047,7 @@ describe('split expense', () => { personalDetails: mockPersonalDetails, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, + formatPhoneNumber: mockFormatPhoneNumber, }); await waitForBatchedUpdates(); @@ -1110,7 +1111,7 @@ describe('split expense', () => { personalDetails: mockPersonalDetails, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, + formatPhoneNumber: mockFormatPhoneNumber, }); waitForBatchedUpdates(); @@ -1161,7 +1162,6 @@ describe('split expense', () => { policyRecentlyUsedCurrencies: [], policyRecentlyUsedTags: undefined, participantsPolicyTags, - formatPhoneNumber: (n: string) => n, delegateAccountID: undefined, }); @@ -1197,7 +1197,6 @@ describe('split expense', () => { personalDetails: mockPersonalDetails, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, sessionEmail: RORY_EMAIL, }); @@ -1343,7 +1342,6 @@ describe('split expense', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -1413,7 +1411,7 @@ describe('split expense', () => { personalDetails: testPersonalDetails, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, + formatPhoneNumber: mockFormatPhoneNumber, }); await waitForBatchedUpdates(); @@ -1477,7 +1475,7 @@ describe('split expense', () => { personalDetails: participantPersonalDetails, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, + formatPhoneNumber: mockFormatPhoneNumber, }); await waitForBatchedUpdates(); @@ -1547,7 +1545,6 @@ describe('split expense', () => { quickAction: undefined, policyRecentlyUsedCurrencies: [], participantsPolicyTags, - formatPhoneNumber: (n: string) => n, delegateAccountID: undefined, }); @@ -1619,7 +1616,6 @@ describe('split expense', () => { personalDetails: completeSplitPersonalDetails, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, sessionEmail: RORY_EMAIL, }); @@ -1666,7 +1662,6 @@ describe('startSplitBill', () => { quickAction: {}, policyRecentlyUsedCurrencies: [], participantsPolicyTags, - formatPhoneNumber: (n: string) => n, delegateAccountID: undefined, }); @@ -1712,7 +1707,6 @@ describe('startSplitBill', () => { policyRecentlyUsedCurrencies: [], policyRecentlyUsedTags: undefined, participantsPolicyTags, - formatPhoneNumber: (n: string) => n, delegateAccountID: undefined, }); @@ -1761,7 +1755,6 @@ describe('startSplitBill', () => { policyRecentlyUsedCurrencies: [], policyRecentlyUsedTags: undefined, participantsPolicyTags, - formatPhoneNumber: (n: string) => n, delegateAccountID: undefined, }); @@ -1881,7 +1874,6 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -2005,7 +1997,6 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -2141,7 +2132,6 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -2222,7 +2212,6 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -2314,7 +2303,6 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -2379,7 +2367,6 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -2459,7 +2446,6 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -2551,7 +2537,6 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -2663,7 +2648,6 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -2843,7 +2827,6 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -2982,7 +2965,6 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -3060,7 +3042,6 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); await getOnyxData({ @@ -3174,7 +3155,6 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -3245,7 +3225,6 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); await getOnyxData({ @@ -3359,7 +3338,6 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -3435,7 +3413,6 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -3558,7 +3535,6 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -3635,7 +3611,6 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -3780,7 +3755,6 @@ describe('updateSplitTransactionsFromSplitExpensesFlow', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -3900,7 +3874,6 @@ describe('updateSplitTransactions', () => { existingTransactionDraft: undefined, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -3971,7 +3944,6 @@ describe('updateSplitTransactions', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -4040,7 +4012,6 @@ describe('updateSplitTransactions', () => { draftTransactionIDs: [], delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -4111,7 +4082,6 @@ describe('updateSplitTransactions', () => { isOffline: true, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -4180,7 +4150,6 @@ describe('updateSplitTransactions', () => { existingTransactionDraft: undefined, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -4249,7 +4218,6 @@ describe('updateSplitTransactions', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -4331,7 +4299,6 @@ describe('updateSplitTransactions', () => { personalDetails: {}, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -4436,7 +4403,6 @@ describe('updateSplitTransactions', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -4504,7 +4470,6 @@ describe('updateSplitTransactions', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, }); const updateSplitTransactionCall = writeSpy.mock.calls.find(([command]) => command === WRITE_COMMANDS.UPDATE_SPLIT_TRANSACTION); @@ -4766,7 +4731,6 @@ describe('updateSplitTransactions', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -4881,7 +4845,6 @@ describe('updateSplitTransactions', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -4960,7 +4923,6 @@ describe('updateSplitTransactions', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -5032,7 +4994,6 @@ describe('updateSplitTransactions', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -5109,7 +5070,6 @@ describe('updateSplitTransactions', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -5181,7 +5141,6 @@ describe('updateSplitTransactions', () => { isOffline: false, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); @@ -7673,7 +7632,7 @@ describe('createDistanceRequest', () => { betas: [CONST.BETAS.ALL], delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: (n: string) => n, + formatPhoneNumber: mockFormatPhoneNumber, }; } @@ -8211,7 +8170,6 @@ describe('startSplitBill delegateAccountID forwarding', () => { policyRecentlyUsedTags: undefined, participantsPolicyTags, delegateAccountID: DELEGATE_ACCOUNT_ID, - formatPhoneNumber: (n: string) => n, }); await waitForBatchedUpdates(); From 2ad23685f6d97bb1f793aca2d34e93ae60c9c539 Mon Sep 17 00:00:00 2001 From: Maruf Sharifi Date: Fri, 17 Jul 2026 14:18:16 +0300 Subject: [PATCH 10/12] Thread phone formatter through split and duplicate flows --- src/libs/actions/IOU/Duplicate.ts | 17 +++++++-- src/libs/actions/IOU/Split.ts | 20 ++++++----- ...andleMoneyRequestStepDistanceNavigation.ts | 5 ++- tests/actions/IOU/SplitReportTotalsTest.ts | 5 ++- tests/actions/IOUTest/SplitTest.ts | 35 +++++++++++-------- 5 files changed, 52 insertions(+), 30 deletions(-) diff --git a/src/libs/actions/IOU/Duplicate.ts b/src/libs/actions/IOU/Duplicate.ts index 86cf1714ca3a..8a80219cc518 100644 --- a/src/libs/actions/IOU/Duplicate.ts +++ b/src/libs/actions/IOU/Duplicate.ts @@ -1,4 +1,4 @@ -import type {LocalizedTranslate} from '@components/LocaleContextProvider'; +import type {LocaleContextProps, LocalizedTranslate} from '@components/LocaleContextProvider'; import type {SelectedReports} from '@components/Search/types'; import * as API from '@libs/API'; @@ -7,7 +7,6 @@ import {WRITE_COMMANDS} from '@libs/API/types'; import DateUtils from '@libs/DateUtils'; import {getMicroSecondOnyxErrorWithTranslationKey} from '@libs/ErrorUtils'; import {getExistingTransactionID} from '@libs/IOUUtils'; -import {formatPhoneNumber} from '@libs/LocalePhoneNumber'; import * as NumberUtils from '@libs/NumberUtils'; import Parser from '@libs/Parser'; import {isInstantSubmitEnabled, isPolicyAccessible, isSubmitAndClose} from '@libs/PolicyUtils'; @@ -653,6 +652,7 @@ function createExpenseByType({ personalDetails, recentWaypoints, isTrackIntentUser, + formatPhoneNumber, }: { transactionType: string; params: RequestMoneyInformation; @@ -666,6 +666,7 @@ function createExpenseByType({ personalDetails: OnyxEntry; recentWaypoints: OnyxEntry; isTrackIntentUser: boolean | undefined; + formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; }) { switch (transactionType) { case CONST.SEARCH.TRANSACTION_TYPE.DISTANCE: { @@ -754,6 +755,7 @@ type DuplicateExpenseTransactionParams = { isTrackIntentUser: boolean | undefined; delegateAccountID: number | undefined; policyTagList: OnyxTypes.PolicyTagLists; + formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; }; function duplicateExpenseTransaction({ @@ -782,6 +784,7 @@ function duplicateExpenseTransaction({ isTrackIntentUser, delegateAccountID, policyTagList, + formatPhoneNumber, }: DuplicateExpenseTransactionParams) { if (!transaction) { return; @@ -895,6 +898,7 @@ function duplicateExpenseTransaction({ personalDetails, recentWaypoints, isTrackIntentUser, + formatPhoneNumber, }); } @@ -921,6 +925,7 @@ type DuplicateReportParams = { shouldPlaySound?: boolean; isTrackIntentUser: boolean | undefined; delegateAccountID: number | undefined; + formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; }; function duplicateReport({ @@ -946,6 +951,7 @@ function duplicateReport({ shouldPlaySound = true, isTrackIntentUser, delegateAccountID, + formatPhoneNumber, }: DuplicateReportParams) { if (!targetPolicy || !parentChatReport) { return; @@ -1063,6 +1069,7 @@ function duplicateReport({ personalDetails, recentWaypoints, isTrackIntentUser, + formatPhoneNumber, }); if (result?.iouReport) { @@ -1097,6 +1104,7 @@ type BulkDuplicateExpensesParams = { isTrackIntentUser: boolean | undefined; delegateAccountID: number | undefined; policyTagList: OnyxTypes.PolicyTagLists; + formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; }; function bulkDuplicateExpenses({ @@ -1121,6 +1129,7 @@ function bulkDuplicateExpenses({ isTrackIntentUser, delegateAccountID, policyTagList, + formatPhoneNumber, }: BulkDuplicateExpensesParams) { const transactionsToDuplicate = transactionIDs.map((id) => allTransactions[`${ONYXKEYS.COLLECTION.TRANSACTION}${id}`]).filter((t): t is OnyxTypes.Transaction => !!t); @@ -1219,6 +1228,7 @@ function bulkDuplicateExpenses({ isTrackIntentUser, delegateAccountID, policyTagList, + formatPhoneNumber, }); if (result?.iouReport) { @@ -1256,6 +1266,7 @@ type BulkDuplicateReportsParams = { currentUserAccountID: number; isTrackIntentUser: boolean | undefined; delegateAccountID: number | undefined; + formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; }; function bulkDuplicateReports({ @@ -1281,6 +1292,7 @@ function bulkDuplicateReports({ currentUserAccountID, isTrackIntentUser, delegateAccountID, + formatPhoneNumber, }: BulkDuplicateReportsParams) { const allTransactionsMap = getAllTransactions(); const transactionsByReportID = new Map(); @@ -1357,6 +1369,7 @@ function bulkDuplicateReports({ currentUserLogin, isTrackIntentUser, delegateAccountID, + formatPhoneNumber, }); } diff --git a/src/libs/actions/IOU/Split.ts b/src/libs/actions/IOU/Split.ts index ef26a8fd3d82..47b2131268e0 100644 --- a/src/libs/actions/IOU/Split.ts +++ b/src/libs/actions/IOU/Split.ts @@ -9,7 +9,6 @@ import DateUtils from '@libs/DateUtils'; import {deferOrExecuteWrite} from '@libs/deferredLayoutWrite'; import {getMicroSecondOnyxErrorWithTranslationKey} from '@libs/ErrorUtils'; import {calculateAmount as calculateIOUAmount, updateIOUOwnerAndTotal} from '@libs/IOUUtils'; -import {formatPhoneNumber} from '@libs/LocalePhoneNumber'; import * as Localize from '@libs/Localize'; import Navigation from '@libs/Navigation/Navigation'; import TransitionTracker from '@libs/Navigation/TransitionTracker'; @@ -198,6 +197,7 @@ type StartSplitBilActionParams = { policyRecentlyUsedCurrencies: string[]; participantsPolicyTags: Record; delegateAccountID: number | undefined; + formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; }; type CompleteSplitBillActionParams = { @@ -213,6 +213,7 @@ type CompleteSplitBillActionParams = { delegateAccountID: number | undefined; isTrackIntentUser: boolean | undefined; sessionEmail?: string; + formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; }; type SplitBillActionsParams = { @@ -285,7 +286,7 @@ function splitBill({ shouldDeferForSearch = false, delegateAccountID, isTrackIntentUser, - formatPhoneNumber: formatPhoneNumberParam, + formatPhoneNumber, }: SplitBillActionsParams) { const parsedComment = getParsedComment(comment); const {splitData, splits, onyxData} = createSplitsAndOnyxData({ @@ -321,7 +322,7 @@ function splitBill({ participantsPolicyTags: buildParticipantsPolicyTags(participants), delegateAccountID, isTrackIntentUser, - formatPhoneNumber: formatPhoneNumberParam, + formatPhoneNumber, }); const parameters: SplitBillParams = { @@ -401,7 +402,7 @@ function splitBillAndOpenReport({ shouldDeferForSearch = false, delegateAccountID, isTrackIntentUser, - formatPhoneNumber: formatPhoneNumberParam, + formatPhoneNumber, }: SplitBillActionsParams) { const parsedComment = getParsedComment(comment); const {splitData, splits, onyxData} = createSplitsAndOnyxData({ @@ -437,7 +438,7 @@ function splitBillAndOpenReport({ participantsPolicyTags: buildParticipantsPolicyTags(participants), delegateAccountID, isTrackIntentUser, - formatPhoneNumber: formatPhoneNumberParam, + formatPhoneNumber, }); const parameters: SplitBillParams = { @@ -511,6 +512,7 @@ function startSplitBill({ shouldHandleNavigation = true, shouldDeferForSearch = false, delegateAccountID, + formatPhoneNumber, }: StartSplitBilActionParams) { const currentUserEmailForIOUSplit = addSMSDomainIfPhoneNumber(currentUserLogin); const participantAccountIDs = participants.map((participant) => Number(participant.accountID)); @@ -1433,7 +1435,7 @@ function createSplitsAndOnyxData({ participantsPolicyTags, delegateAccountID, isTrackIntentUser, - formatPhoneNumber: formatPhoneNumberParam, + formatPhoneNumber, }: CreateSplitsAndOnyxDataParams): SplitsAndOnyxData { const currentUserEmailForIOUSplit = addSMSDomainIfPhoneNumber(currentUserLogin); const participantAccountIDs = participants.map((participant) => Number(participant.accountID)); @@ -1816,7 +1818,7 @@ function createSplitsAndOnyxData({ accountID, // Disabling this line since participant.displayName can be an empty string // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - displayName: formatPhoneNumberParam(participant.displayName || email), + displayName: formatPhoneNumber(participant.displayName || email), login: participant.login, isOptimisticPersonalDetail: true, }, @@ -1968,7 +1970,7 @@ function createDistanceRequest(distanceRequestInformation: CreateDistanceRequest previousOdometerDraft, delegateAccountID, isTrackIntentUser, - formatPhoneNumber: formatPhoneNumberParam, + formatPhoneNumber, } = distanceRequestInformation; const {policy, policyCategories, policyTagList, policyRecentlyUsedCategories, policyRecentlyUsedTags} = policyParams; const parsedComment = getParsedComment(transactionParams.comment); @@ -2061,7 +2063,7 @@ function createDistanceRequest(distanceRequestInformation: CreateDistanceRequest participantsPolicyTags: buildParticipantsPolicyTags(participants), delegateAccountID, isTrackIntentUser, - formatPhoneNumber: formatPhoneNumberParam, + formatPhoneNumber, }); onyxData = splitOnyxData; diff --git a/src/pages/iou/request/step/IOURequestStepDistance/handleMoneyRequestStepDistanceNavigation.ts b/src/pages/iou/request/step/IOURequestStepDistance/handleMoneyRequestStepDistanceNavigation.ts index c87393ebb1d4..94b77632a435 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance/handleMoneyRequestStepDistanceNavigation.ts +++ b/src/pages/iou/request/step/IOURequestStepDistance/handleMoneyRequestStepDistanceNavigation.ts @@ -1,3 +1,5 @@ +import type {LocaleContextProps} from '@components/LocaleContextProvider'; + import { getMoneyRequestParticipantOptions, setCustomUnitRateID, @@ -12,7 +14,6 @@ import {getCurrencySymbol} from '@libs/CurrencyUtils'; import DistanceRequestUtils from '@libs/DistanceRequestUtils'; import {calculateDefaultReimbursable, getExistingTransactionID, navigateToConfirmationPage, navigateToParticipantPage} from '@libs/IOUUtils'; import {toLocaleDigit} from '@libs/LocaleDigitUtils'; -import {formatPhoneNumber} from '@libs/LocalePhoneNumber'; import cleanupAfterSkipConfirmSubmit from '@libs/Navigation/helpers/cleanupAfterSkipConfirmSubmit'; import {submitWithDismissFirst} from '@libs/Navigation/helpers/submitWithDismissFirst'; import Navigation from '@libs/Navigation/Navigation'; @@ -105,6 +106,7 @@ type MoneyRequestStepDistanceNavigationParams = { isTrackIntentUser: boolean | undefined; delegateAccountID: number | undefined; policyTagList: PolicyTagLists; + formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; }; /** Amount + merchant for a manual-distance submit; pending placeholders otherwise (waypoint/GPS distance is computed server-side). */ @@ -202,6 +204,7 @@ function handleMoneyRequestStepDistanceNavigation({ isTrackIntentUser, delegateAccountID, policyTagList, + formatPhoneNumber, }: MoneyRequestStepDistanceNavigationParams): void { const isManualDistance = manualDistance !== undefined; const isOdometerDistance = odometerDistance !== undefined; diff --git a/tests/actions/IOU/SplitReportTotalsTest.ts b/tests/actions/IOU/SplitReportTotalsTest.ts index c10f9aa8e03f..0db4c8b418ef 100644 --- a/tests/actions/IOU/SplitReportTotalsTest.ts +++ b/tests/actions/IOU/SplitReportTotalsTest.ts @@ -23,11 +23,10 @@ import type {OnyxEntry, OnyxMergeCollectionInput} from 'react-native-onyx'; import Onyx from 'react-native-onyx'; import currencyList from '../../unit/currencyList.json'; -import {getGlobalFetchMock} from '../../utils/TestHelper'; +import {getGlobalFetchMock, formatPhoneNumber} from '../../utils/TestHelper'; import waitForBatchedUpdates from '../../utils/waitForBatchedUpdates'; const topMostReportID = '23423423'; -const mockFormatPhoneNumber = (phoneNumber: string) => phoneNumber; jest.mock('@src/libs/Navigation/Navigation', () => ({ navigate: jest.fn(), dismissModal: jest.fn(), @@ -508,7 +507,7 @@ describe('actions/IOU', () => { participantsPolicyTags: overrides.participantsPolicyTags ?? {}, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: mockFormatPhoneNumber, + formatPhoneNumber, }); it('returns valid splitData with chatReportID, transactionID, and reportActionID', () => { diff --git a/tests/actions/IOUTest/SplitTest.ts b/tests/actions/IOUTest/SplitTest.ts index bcb78ba20785..434a6247741c 100644 --- a/tests/actions/IOUTest/SplitTest.ts +++ b/tests/actions/IOUTest/SplitTest.ts @@ -56,7 +56,7 @@ import {createRandomReport} from '../../utils/collections/reports'; import createRandomTransaction from '../../utils/collections/transaction'; import getOnyxValue from '../../utils/getOnyxValue'; import initCurrencyListContext from '../../utils/initCurrencyListContext'; -import {getGlobalFetchMock, getOnyxData, translateLocal} from '../../utils/TestHelper'; +import {formatPhoneNumber, getGlobalFetchMock, getOnyxData, translateLocal} from '../../utils/TestHelper'; import waitForBatchedUpdates from '../../utils/waitForBatchedUpdates'; import waitForNetworkPromises from '../../utils/waitForNetworkPromises'; @@ -110,7 +110,6 @@ jest.mock('@libs/deferredLayoutWrite', () => ({ jest.mock('@hooks/useCardFeedsForDisplay', () => jest.fn(() => ({defaultCardFeed: null, cardFeedsByPolicy: {}}))); const unapprovedCashHash = 71801560; -const mockFormatPhoneNumber = (phoneNumber: string) => phoneNumber; jest.mock('@src/libs/SearchQueryUtils', () => { const actual = jest.requireActual('@src/libs/SearchQueryUtils'); // eslint-disable-next-line @typescript-eslint/no-unsafe-return @@ -415,7 +414,7 @@ describe('split expense', () => { personalDetails: mockPersonalDetails, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: mockFormatPhoneNumber, + formatPhoneNumber, }, ); return waitForBatchedUpdates(); @@ -753,7 +752,7 @@ describe('split expense', () => { personalDetails: mockPersonalDetails, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: mockFormatPhoneNumber, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -805,7 +804,7 @@ describe('split expense', () => { personalDetails: mockPersonalDetails, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: mockFormatPhoneNumber, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -831,7 +830,7 @@ describe('split expense', () => { personalDetails: mockPersonalDetails, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: mockFormatPhoneNumber, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -864,7 +863,7 @@ describe('split expense', () => { personalDetails: mockPersonalDetails, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: mockFormatPhoneNumber, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -902,7 +901,7 @@ describe('split expense', () => { personalDetails: mockPersonalDetails, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: mockFormatPhoneNumber, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -926,7 +925,7 @@ describe('split expense', () => { personalDetails: mockPersonalDetails, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: mockFormatPhoneNumber, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -994,7 +993,7 @@ describe('split expense', () => { personalDetails: mockPersonalDetails, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: mockFormatPhoneNumber, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -1047,7 +1046,7 @@ describe('split expense', () => { personalDetails: mockPersonalDetails, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: mockFormatPhoneNumber, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -1111,7 +1110,7 @@ describe('split expense', () => { personalDetails: mockPersonalDetails, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: mockFormatPhoneNumber, + formatPhoneNumber, }); waitForBatchedUpdates(); @@ -1163,6 +1162,7 @@ describe('split expense', () => { policyRecentlyUsedTags: undefined, participantsPolicyTags, delegateAccountID: undefined, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -1411,7 +1411,7 @@ describe('split expense', () => { personalDetails: testPersonalDetails, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: mockFormatPhoneNumber, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -1475,7 +1475,7 @@ describe('split expense', () => { personalDetails: participantPersonalDetails, delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: mockFormatPhoneNumber, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -1546,6 +1546,7 @@ describe('split expense', () => { policyRecentlyUsedCurrencies: [], participantsPolicyTags, delegateAccountID: undefined, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -1663,6 +1664,7 @@ describe('startSplitBill', () => { policyRecentlyUsedCurrencies: [], participantsPolicyTags, delegateAccountID: undefined, + formatPhoneNumber, }); waitForBatchedUpdates(); @@ -1708,6 +1710,7 @@ describe('startSplitBill', () => { policyRecentlyUsedTags: undefined, participantsPolicyTags, delegateAccountID: undefined, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -1756,6 +1759,7 @@ describe('startSplitBill', () => { policyRecentlyUsedTags: undefined, participantsPolicyTags, delegateAccountID: undefined, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -7632,7 +7636,7 @@ describe('createDistanceRequest', () => { betas: [CONST.BETAS.ALL], delegateAccountID: undefined, isTrackIntentUser: false, - formatPhoneNumber: mockFormatPhoneNumber, + formatPhoneNumber, }; } @@ -8170,6 +8174,7 @@ describe('startSplitBill delegateAccountID forwarding', () => { policyRecentlyUsedTags: undefined, participantsPolicyTags, delegateAccountID: DELEGATE_ACCOUNT_ID, + formatPhoneNumber, }); await waitForBatchedUpdates(); From 4c049f2194cc5f394531e1f8f2bc7300f1ef05d6 Mon Sep 17 00:00:00 2001 From: Maruf Sharifi Date: Fri, 17 Jul 2026 15:34:43 +0300 Subject: [PATCH 11/12] fixed type failure --- src/libs/actions/IOU/Split.ts | 1 + src/pages/iou/request/step/confirmation/useExpenseSubmission.ts | 1 + tests/actions/IOUTest/SplitTest.ts | 2 ++ 3 files changed, 4 insertions(+) diff --git a/src/libs/actions/IOU/Split.ts b/src/libs/actions/IOU/Split.ts index 47b2131268e0..15370d7f6ef2 100644 --- a/src/libs/actions/IOU/Split.ts +++ b/src/libs/actions/IOU/Split.ts @@ -704,6 +704,7 @@ function startSplitBill({ policyRecentlyUsedTags, participantsPolicyTags, delegateAccountID, + formatPhoneNumber, }; if (existingSplitChatReport) { diff --git a/src/pages/iou/request/step/confirmation/useExpenseSubmission.ts b/src/pages/iou/request/step/confirmation/useExpenseSubmission.ts index fc0f0a4d4e59..4b428d7e761f 100644 --- a/src/pages/iou/request/step/confirmation/useExpenseSubmission.ts +++ b/src/pages/iou/request/step/confirmation/useExpenseSubmission.ts @@ -876,6 +876,7 @@ function useExpenseSubmission(params: UseExpenseSubmissionParams) { shouldHandleNavigation, shouldDeferForSearch: shouldDeferSplitForSearch, delegateAccountID, + formatPhoneNumber, }); } } diff --git a/tests/actions/IOUTest/SplitTest.ts b/tests/actions/IOUTest/SplitTest.ts index 434a6247741c..1348e9aa9271 100644 --- a/tests/actions/IOUTest/SplitTest.ts +++ b/tests/actions/IOUTest/SplitTest.ts @@ -1198,6 +1198,7 @@ describe('split expense', () => { delegateAccountID: undefined, isTrackIntentUser: false, sessionEmail: RORY_EMAIL, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -1618,6 +1619,7 @@ describe('split expense', () => { delegateAccountID: undefined, isTrackIntentUser: false, sessionEmail: RORY_EMAIL, + formatPhoneNumber, }); await waitForBatchedUpdates(); From 021810f32c47c4354e33afe31aa572c39d01a7cb Mon Sep 17 00:00:00 2001 From: Maruf Sharifi Date: Fri, 17 Jul 2026 18:31:13 +0300 Subject: [PATCH 12/12] Pass phone formatter through remaining IOU flows --- .../MoneyRequestHeaderSecondaryActions.tsx | 3 ++- src/hooks/useBulkDuplicateAction.ts | 3 +++ src/hooks/useBulkDuplicateReportAction.ts | 3 ++- src/hooks/useExpenseActions.ts | 4 +++- src/pages/iou/DynamicSplitBillDetailsPage.tsx | 4 +++- .../hooks/useDistanceNavigation.ts | 3 +++ .../hooks/useOdometerNavigation.ts | 3 +++ .../index.native.tsx | 3 ++- .../step/IOURequestStepDistanceManual.tsx | 3 ++- .../components/ScanSkipConfirmation.tsx | 3 ++- tests/actions/IOU/MoneyRequestTest.ts | 4 +++- tests/actions/IOUTest/DuplicateTest.ts | 20 ++++++++++++++++++- 12 files changed, 47 insertions(+), 9 deletions(-) diff --git a/src/components/MoneyRequestHeaderSecondaryActions.tsx b/src/components/MoneyRequestHeaderSecondaryActions.tsx index dc640cf73251..ea24887129b9 100644 --- a/src/components/MoneyRequestHeaderSecondaryActions.tsx +++ b/src/components/MoneyRequestHeaderSecondaryActions.tsx @@ -110,7 +110,7 @@ function MoneyRequestHeaderSecondaryActions({reportID, onBackButtonPress}: Money >(); const styles = useThemeStyles(); const theme = useTheme(); - const {translate, localeCompare} = useLocalize(); + const {translate, localeCompare, formatPhoneNumber} = useLocalize(); const {login: currentUserLogin, accountID, localCurrencyCode} = useCurrentUserPersonalDetails(); const delegateAccountID = useDelegateAccountID(); const personalDetails = usePersonalDetails(); @@ -270,6 +270,7 @@ function MoneyRequestHeaderSecondaryActions({reportID, onBackButtonPress}: Money isTrackIntentUser, delegateAccountID, policyTagList, + formatPhoneNumber, }); } }; diff --git a/src/hooks/useBulkDuplicateAction.ts b/src/hooks/useBulkDuplicateAction.ts index 4136ed96550b..c28cf74a11eb 100644 --- a/src/hooks/useBulkDuplicateAction.ts +++ b/src/hooks/useBulkDuplicateAction.ts @@ -16,6 +16,7 @@ import {validTransactionDraftsSelector} from '@selectors/TransactionDraft'; import useCurrentUserPersonalDetails from './useCurrentUserPersonalDetails'; import useDefaultExpensePolicy from './useDefaultExpensePolicy'; import useDelegateAccountID from './useDelegateAccountID'; +import useLocalize from './useLocalize'; import useMoneyRequestPolicyTagsForReport from './useMoneyRequestPolicyTagsForReport'; import useOnyx from './useOnyx'; import usePermissions from './usePermissions'; @@ -36,6 +37,7 @@ type UseBulkDuplicateActionParams = { function useBulkDuplicateAction({selectedTransactionsKeys, allTransactions, allReports, searchData, onAfterDuplicate}: UseBulkDuplicateActionParams) { const {accountID, login: currentUserLogin, localCurrencyCode} = useCurrentUserPersonalDetails(); const delegateAccountID = useDelegateAccountID(); + const {formatPhoneNumber} = useLocalize(); const {clearSelectedTransactions} = useSearchSelectionActions(); const defaultExpensePolicy = useDefaultExpensePolicy(); const {isBetaEnabled} = usePermissions(); @@ -90,6 +92,7 @@ function useBulkDuplicateAction({selectedTransactionsKeys, allTransactions, allR isTrackIntentUser, delegateAccountID, policyTagList, + formatPhoneNumber, }); if (onAfterDuplicate) { diff --git a/src/hooks/useBulkDuplicateReportAction.ts b/src/hooks/useBulkDuplicateReportAction.ts index de09344c4e83..d97aac284e27 100644 --- a/src/hooks/useBulkDuplicateReportAction.ts +++ b/src/hooks/useBulkDuplicateReportAction.ts @@ -32,7 +32,7 @@ function useBulkDuplicateReportAction({selectedReports, allReports, searchData}: const defaultExpensePolicy = useDefaultExpensePolicy(); const {isBetaEnabled} = usePermissions(); const isASAPSubmitBetaEnabled = isBetaEnabled(CONST.BETAS.ASAP_SUBMIT); - const {translate} = useLocalize(); + const {translate, formatPhoneNumber} = useLocalize(); const [quickAction] = useOnyx(ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE); const [policyRecentlyUsedCurrencies] = useOnyx(ONYXKEYS.RECENTLY_USED_CURRENCIES); @@ -72,6 +72,7 @@ function useBulkDuplicateReportAction({selectedReports, allReports, searchData}: currentUserAccountID: currentUserPersonalDetails?.accountID, isTrackIntentUser, delegateAccountID, + formatPhoneNumber, }); clearSelectedTransactions(undefined, true); diff --git a/src/hooks/useExpenseActions.ts b/src/hooks/useExpenseActions.ts index d4b0b7f1906a..d2fe99385687 100644 --- a/src/hooks/useExpenseActions.ts +++ b/src/hooks/useExpenseActions.ts @@ -98,7 +98,7 @@ type UseExpenseActionsReturn = { function useExpenseActions({reportID, isReportInSearch = false, backTo, onDuplicateReset}: UseExpenseActionsParams): UseExpenseActionsReturn { const theme = useTheme(); - const {translate, localeCompare} = useLocalize(); + const {translate, localeCompare, formatPhoneNumber} = useLocalize(); const {isProduction} = useEnvironment(); const {isBetaEnabled} = usePermissions(); const isASAPSubmitBetaEnabled = isBetaEnabled(CONST.BETAS.ASAP_SUBMIT); @@ -279,6 +279,7 @@ function useExpenseActions({reportID, isReportInSearch = false, backTo, onDuplic isTrackIntentUser, delegateAccountID, policyTagList, + formatPhoneNumber, }); } }; @@ -439,6 +440,7 @@ function useExpenseActions({reportID, isReportInSearch = false, backTo, onDuplic currentUserLogin: currentUserPersonalDetails?.email ?? '', isTrackIntentUser, delegateAccountID, + formatPhoneNumber, }); }, }, diff --git a/src/pages/iou/DynamicSplitBillDetailsPage.tsx b/src/pages/iou/DynamicSplitBillDetailsPage.tsx index e6285867e022..ee0d2e423a87 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']); @@ -110,6 +110,7 @@ function DynamicSplitBillDetailsPage({report, reportAction}: SplitBillDetailsPag delegateAccountID, isTrackIntentUser, sessionEmail: session?.email, + formatPhoneNumber, }); }, [ reportID, @@ -124,6 +125,7 @@ function DynamicSplitBillDetailsPage({report, reportAction}: SplitBillDetailsPag personalDetails, delegateAccountID, isTrackIntentUser, + formatPhoneNumber, ]); return ( diff --git a/src/pages/iou/request/step/IOURequestStepDistance/hooks/useDistanceNavigation.ts b/src/pages/iou/request/step/IOURequestStepDistance/hooks/useDistanceNavigation.ts index b96ae0e3b4cd..dfdeddd92339 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance/hooks/useDistanceNavigation.ts +++ b/src/pages/iou/request/step/IOURequestStepDistance/hooks/useDistanceNavigation.ts @@ -1,6 +1,7 @@ import type {LocaleContextProps} from '@components/LocaleContextProvider'; import useDelegateAccountID from '@hooks/useDelegateAccountID'; +import useLocalize from '@hooks/useLocalize'; import useMoneyRequestPolicyTagsForReport from '@hooks/useMoneyRequestPolicyTagsForReport'; import useOnyx from '@hooks/useOnyx'; @@ -149,6 +150,7 @@ function useDistanceNavigation({ const [isTrackIntentUser] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED, {selector: isTrackIntentUserSelector}); const delegateAccountID = useDelegateAccountID(); + const {formatPhoneNumber} = useLocalize(); const policyTagList = useMoneyRequestPolicyTagsForReport({report, currentUserAccountID}); return () => { const optimisticTransactionID = rand64(); @@ -198,6 +200,7 @@ function useDistanceNavigation({ isTrackIntentUser, delegateAccountID, policyTagList, + formatPhoneNumber, }); }; } diff --git a/src/pages/iou/request/step/IOURequestStepDistance/hooks/useOdometerNavigation.ts b/src/pages/iou/request/step/IOURequestStepDistance/hooks/useOdometerNavigation.ts index 90bc2807c0f0..a0dcabca201b 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance/hooks/useOdometerNavigation.ts +++ b/src/pages/iou/request/step/IOURequestStepDistance/hooks/useOdometerNavigation.ts @@ -1,6 +1,7 @@ import type {LocaleContextProps} from '@components/LocaleContextProvider'; import useDelegateAccountID from '@hooks/useDelegateAccountID'; +import useLocalize from '@hooks/useLocalize'; import useMoneyRequestPolicyTagsForReport from '@hooks/useMoneyRequestPolicyTagsForReport'; import useOnyx from '@hooks/useOnyx'; @@ -153,6 +154,7 @@ function useOdometerNavigation({ const policyTagList = useMoneyRequestPolicyTagsForReport({report, currentUserAccountID}); const delegateAccountID = useDelegateAccountID(); + const {formatPhoneNumber} = useLocalize(); return ({odometerStart, odometerEnd, odometerDistance, unit, previousOdometerDraft}: NavigateOptions) => { const optimisticTransactionID = rand64(); @@ -205,6 +207,7 @@ function useOdometerNavigation({ isTrackIntentUser, delegateAccountID, policyTagList, + formatPhoneNumber, }); }; } diff --git a/src/pages/iou/request/step/IOURequestStepDistanceGPS/index.native.tsx b/src/pages/iou/request/step/IOURequestStepDistanceGPS/index.native.tsx index 991198073ef6..29d921b1f9b6 100644 --- a/src/pages/iou/request/step/IOURequestStepDistanceGPS/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistanceGPS/index.native.tsx @@ -60,7 +60,7 @@ function IOURequestStepDistanceGPS({ const styles = useThemeStyles(); const delegateAccountID = useDelegateAccountID(); - const {translate} = useLocalize(); + const {translate, formatPhoneNumber} = useLocalize(); const {isBetaEnabled} = usePermissions(); const isInLandscapeMode = useIsInLandscapeMode(); @@ -174,6 +174,7 @@ function IOURequestStepDistanceGPS({ isTrackIntentUser, delegateAccountID, policyTagList, + formatPhoneNumber, }); }; diff --git a/src/pages/iou/request/step/IOURequestStepDistanceManual.tsx b/src/pages/iou/request/step/IOURequestStepDistanceManual.tsx index 1fc2ae19097f..2a56210e7519 100644 --- a/src/pages/iou/request/step/IOURequestStepDistanceManual.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistanceManual.tsx @@ -72,7 +72,7 @@ function IOURequestStepDistanceManual({ transaction, currentUserPersonalDetails, }: IOURequestStepDistanceManualProps) { - const {translate} = useLocalize(); + const {translate, formatPhoneNumber} = useLocalize(); const styles = useThemeStyles(); const {isBetaEnabled} = usePermissions(); const {isExtraSmallScreenHeight} = useResponsiveLayout(); @@ -296,6 +296,7 @@ function IOURequestStepDistanceManual({ isTrackIntentUser, delegateAccountID, policyTagList, + formatPhoneNumber, }); }; diff --git a/src/pages/iou/request/step/IOURequestStepScan/components/ScanSkipConfirmation.tsx b/src/pages/iou/request/step/IOURequestStepScan/components/ScanSkipConfirmation.tsx index a3e90a130f0e..0fb03f852873 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/components/ScanSkipConfirmation.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/components/ScanSkipConfirmation.tsx @@ -108,7 +108,7 @@ function ScanSkipConfirmation({report, action, iouType, reportID, transactionID, const [transactions] = useOptimisticDraftTransactions(transaction); const {isMultiScanEnabled} = useMultiScanState(); - const {translate} = useLocalize(); + const {translate, formatPhoneNumber} = useLocalize(); const {disableMultiScan} = useMultiScanActions(); const {setIsLoaderVisible} = useFullScreenLoaderActions(); const [startLocationPermissionFlow, setStartLocationPermissionFlow] = useState(false); @@ -227,6 +227,7 @@ function ScanSkipConfirmation({report, action, iouType, reportID, transactionID, policyRecentlyUsedTags: undefined, participantsPolicyTags, delegateAccountID, + formatPhoneNumber, }; submitWithDismissFirst({ diff --git a/tests/actions/IOU/MoneyRequestTest.ts b/tests/actions/IOU/MoneyRequestTest.ts index 6c4c0337198c..b9878d2a5592 100644 --- a/tests/actions/IOU/MoneyRequestTest.ts +++ b/tests/actions/IOU/MoneyRequestTest.ts @@ -26,7 +26,7 @@ import createRandomPolicy from '../../utils/collections/policies'; import {createRandomReport, createSelfDM} from '../../utils/collections/reports'; import createRandomTransaction from '../../utils/collections/transaction'; import getOnyxValue from '../../utils/getOnyxValue'; -import {translateLocal} from '../../utils/TestHelper'; +import {formatPhoneNumber, translateLocal} from '../../utils/TestHelper'; import waitForBatchedUpdates from '../../utils/waitForBatchedUpdates'; jest.mock('@libs/actions/IOU', () => { @@ -143,6 +143,7 @@ describe('MoneyRequest', () => { currentUserLocalCurrency: undefined, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }; beforeEach(async () => { @@ -677,6 +678,7 @@ describe('MoneyRequest', () => { currentUserLocalCurrency: undefined, policyTagList: {}, isTrackIntentUser: false, + formatPhoneNumber, }; const splitShares: SplitShares = { [firstSplitParticipantID]: { diff --git a/tests/actions/IOUTest/DuplicateTest.ts b/tests/actions/IOUTest/DuplicateTest.ts index b5f5a0f7bcc2..52852a0e839a 100644 --- a/tests/actions/IOUTest/DuplicateTest.ts +++ b/tests/actions/IOUTest/DuplicateTest.ts @@ -37,7 +37,7 @@ import createRandomTransaction from '../../utils/collections/transaction'; import createMock from '../../utils/createMock'; import getOnyxValue from '../../utils/getOnyxValue'; import initCurrencyListContext from '../../utils/initCurrencyListContext'; -import {getGlobalFetchMock, getOnyxData} from '../../utils/TestHelper'; +import {formatPhoneNumber, getGlobalFetchMock, getOnyxData} from '../../utils/TestHelper'; import {isObject} from '../../utils/typeGuards'; import waitForBatchedUpdates from '../../utils/waitForBatchedUpdates'; @@ -1353,6 +1353,7 @@ describe('actions/Duplicate', () => { currentUserLocalCurrency: undefined, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -1420,6 +1421,7 @@ describe('actions/Duplicate', () => { currentUserLocalCurrency: undefined, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -1479,6 +1481,7 @@ describe('actions/Duplicate', () => { currentUserLocalCurrency: undefined, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -1531,6 +1534,7 @@ describe('actions/Duplicate', () => { currentUserLocalCurrency: undefined, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -1583,6 +1587,7 @@ describe('actions/Duplicate', () => { currentUserLocalCurrency: undefined, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -1638,6 +1643,7 @@ describe('actions/Duplicate', () => { currentUserLocalCurrency: undefined, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -1703,6 +1709,7 @@ describe('actions/Duplicate', () => { currentUserLocalCurrency: undefined, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -1753,6 +1760,7 @@ describe('actions/Duplicate', () => { currentUserLocalCurrency: undefined, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -1796,6 +1804,7 @@ describe('actions/Duplicate', () => { currentUserLocalCurrency: undefined, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -1842,6 +1851,7 @@ describe('actions/Duplicate', () => { currentUserLocalCurrency: undefined, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -1894,6 +1904,7 @@ describe('actions/Duplicate', () => { currentUserLocalCurrency: undefined, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -1962,6 +1973,7 @@ describe('actions/Duplicate', () => { currentUserLocalCurrency: undefined, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -2030,6 +2042,7 @@ describe('actions/Duplicate', () => { currentUserLocalCurrency: undefined, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -2081,6 +2094,7 @@ describe('actions/Duplicate', () => { currentUserLocalCurrency: undefined, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -2144,6 +2158,7 @@ describe('actions/Duplicate', () => { currentUserLocalCurrency: undefined, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -2317,6 +2332,7 @@ describe('actions/Duplicate', () => { recentWaypoints: [], isTrackIntentUser: false, delegateAccountID: undefined, + formatPhoneNumber, ...overrides, }); @@ -2889,6 +2905,7 @@ describe('actions/Duplicate', () => { currentUserLocalCurrency: undefined, delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, }); await waitForBatchedUpdates(); @@ -3001,6 +3018,7 @@ describe('actions/Duplicate', () => { recentWaypoints: [], delegateAccountID: undefined, isTrackIntentUser: false, + formatPhoneNumber, ...overrides, });