diff --git a/src/libs/actions/IOU/SendInvoice.ts b/src/libs/actions/IOU/SendInvoice.ts index e97e1cd89e7d..45193a958859 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'; @@ -85,6 +86,7 @@ type SendInvoiceOptions = { policyRecentlyUsedTags?: OnyxEntry; isFromGlobalCreate?: boolean; senderPolicyTags: OnyxEntry; + formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; delegateAccountID: number | undefined; }; @@ -589,6 +591,7 @@ function getSendInvoiceInformation({ policyRecentlyUsedCategories, policyRecentlyUsedTags, senderPolicyTags, + formatPhoneNumber, delegateAccountID, }: SendInvoiceOptions): SendInvoiceInformation { const {amount = 0, currency = '', created = '', merchant = '', category = '', tag = '', taxCode = '', taxAmount = 0, taxValue, billable, comment, participants} = transaction ?? {}; @@ -738,6 +741,7 @@ function sendInvoice({ policyRecentlyUsedTags, isFromGlobalCreate = false, senderPolicyTags, + formatPhoneNumber, delegateAccountID, }: SendInvoiceOptions) { const parsedComment = getParsedComment(transaction?.comment?.comment?.trim() ?? ''); @@ -773,6 +777,7 @@ function sendInvoice({ policyRecentlyUsedCategories, policyRecentlyUsedTags, senderPolicyTags: senderPolicyTags ?? {}, + formatPhoneNumber, delegateAccountID, }); diff --git a/src/pages/iou/request/step/IOURequestStepCompanyInfo.tsx b/src/pages/iou/request/step/IOURequestStepCompanyInfo.tsx index 0668e12fec53..ad7c97abe568 100644 --- a/src/pages/iou/request/step/IOURequestStepCompanyInfo.tsx +++ b/src/pages/iou/request/step/IOURequestStepCompanyInfo.tsx @@ -49,7 +49,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(); @@ -122,6 +122,7 @@ function IOURequestStepCompanyInfo({route, report, transaction}: IOURequestStepC policyRecentlyUsedTags, isFromGlobalCreate, senderPolicyTags: policyTags ?? {}, + formatPhoneNumber, delegateAccountID, }); cleanupAndNavigateAfterExpenseCreate({ diff --git a/src/pages/iou/request/step/confirmation/useExpenseSubmission.ts b/src/pages/iou/request/step/confirmation/useExpenseSubmission.ts index a9233d1be432..8209306b7d8f 100644 --- a/src/pages/iou/request/step/confirmation/useExpenseSubmission.ts +++ b/src/pages/iou/request/step/confirmation/useExpenseSubmission.ts @@ -196,7 +196,7 @@ function useExpenseSubmission(params: UseExpenseSubmissionParams) { } = params; // Localization - const {translate, toLocaleDigit} = useLocalize(); + const {translate, toLocaleDigit, formatPhoneNumber} = useLocalize(); const delegateAccountID = useDelegateAccountID(); // Permissions @@ -1027,6 +1027,7 @@ function useExpenseSubmission(params: UseExpenseSubmissionParams) { isFromGlobalCreate: getIsFromGlobalCreate(transaction), policyRecentlyUsedTags, senderPolicyTags: senderWorkspacePolicyTags ?? {}, + formatPhoneNumber, delegateAccountID, }); if (shouldHandleNavigation) { diff --git a/tests/actions/IOUTest/SendInvoiceTest.ts b/tests/actions/IOUTest/SendInvoiceTest.ts index 96119c1637b1..ec9decad80a4 100644 --- a/tests/actions/IOUTest/SendInvoiceTest.ts +++ b/tests/actions/IOUTest/SendInvoiceTest.ts @@ -27,7 +27,7 @@ import createRandomPolicy from '../../utils/collections/policies'; import createRandomTransaction from '../../utils/collections/transaction'; import getOnyxValue from '../../utils/getOnyxValue'; import initCurrencyListContext from '../../utils/initCurrencyListContext'; -import {getGlobalFetchMock} from '../../utils/TestHelper'; +import {formatPhoneNumber, getGlobalFetchMock} from '../../utils/TestHelper'; import waitForBatchedUpdates from '../../utils/waitForBatchedUpdates'; const topMostReportID = '23423423'; @@ -176,6 +176,7 @@ describe('actions/SendInvoice', () => { companyWebsite: undefined, policyRecentlyUsedCategories: existingRecentlyUsedCategories, senderPolicyTags: baseSenderPolicyTags, + formatPhoneNumber, delegateAccountID: undefined, }); @@ -202,6 +203,7 @@ describe('actions/SendInvoice', () => { companyWebsite: undefined, policyRecentlyUsedCategories: undefined, senderPolicyTags: baseSenderPolicyTags, + formatPhoneNumber, delegateAccountID: undefined, }); @@ -254,6 +256,7 @@ describe('actions/SendInvoice', () => { companyWebsite: 'https://testcompany.com', policyRecentlyUsedCategories: ['Services', 'Consulting'], senderPolicyTags: mockPolicyTagList as PolicyTagLists, + formatPhoneNumber, delegateAccountID: undefined, }); @@ -304,6 +307,7 @@ describe('actions/SendInvoice', () => { companyWebsite: 'https://testcompany.com', policyRecentlyUsedCategories: [], senderPolicyTags: baseSenderPolicyTags, + formatPhoneNumber, delegateAccountID: DELEGATE_ACCOUNT_ID, }); @@ -369,6 +373,7 @@ describe('actions/SendInvoice', () => { companyWebsite: 'https://clientcompany.com', policyRecentlyUsedCategories: [], senderPolicyTags: baseSenderPolicyTags, + formatPhoneNumber, delegateAccountID: undefined, }); @@ -406,6 +411,7 @@ describe('actions/SendInvoice', () => { companyWebsite: undefined, policyRecentlyUsedCategories: [], senderPolicyTags: baseSenderPolicyTags, + formatPhoneNumber, delegateAccountID: undefined, }); @@ -456,6 +462,7 @@ describe('actions/SendInvoice', () => { companyWebsite: undefined, policyRecentlyUsedCategories: [], senderPolicyTags: baseSenderPolicyTags, + formatPhoneNumber, delegateAccountID: undefined, }); @@ -487,6 +494,7 @@ describe('actions/SendInvoice', () => { companyWebsite: undefined, policyRecentlyUsedCategories: [], senderPolicyTags: baseSenderPolicyTags, + formatPhoneNumber, delegateAccountID: undefined, }); @@ -540,6 +548,7 @@ describe('actions/SendInvoice', () => { companyWebsite: undefined, policyRecentlyUsedCategories: [], senderPolicyTags: baseSenderPolicyTags, + formatPhoneNumber, delegateAccountID: undefined, }); @@ -594,6 +603,7 @@ describe('actions/SendInvoice', () => { policyRecentlyUsedCurrencies: [], policyRecentlyUsedTags, senderPolicyTags: senderPolicyTags ?? {}, + formatPhoneNumber, delegateAccountID: undefined, }); @@ -642,6 +652,7 @@ describe('actions/SendInvoice', () => { currentUserAccountID: 123, policyRecentlyUsedCurrencies: [], senderPolicyTags: senderPolicyTags ?? {}, + formatPhoneNumber, delegateAccountID: undefined, }); @@ -675,6 +686,7 @@ describe('actions/SendInvoice', () => { companyName, companyWebsite, senderPolicyTags: undefined, + formatPhoneNumber, delegateAccountID: undefined, }); @@ -704,6 +716,7 @@ describe('actions/SendInvoice', () => { transaction, policyRecentlyUsedCurrencies: initialCurrencies, senderPolicyTags: undefined, + formatPhoneNumber, delegateAccountID: undefined, }); @@ -745,6 +758,7 @@ describe('actions/SendInvoice', () => { policyRecentlyUsedCurrencies: [], policyRecentlyUsedCategories, senderPolicyTags: undefined, + formatPhoneNumber, delegateAccountID: undefined, }); @@ -787,6 +801,7 @@ describe('actions/SendInvoice', () => { orderWeight: 0, }, }, + formatPhoneNumber, delegateAccountID: undefined, }); await waitForBatchedUpdates(); @@ -823,6 +838,7 @@ describe('actions/SendInvoice', () => { policyRecentlyUsedCurrencies: [], invoiceChatReportID: preGeneratedReportID, senderPolicyTags: undefined, + formatPhoneNumber, delegateAccountID: undefined, });