Skip to content
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/libs/actions/IOU/Duplicate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -701,6 +702,7 @@ function createExpenseByType({
customUnitPolicyID,
personalDetails,
recentWaypoints,
formatPhoneNumber,
};
return createDistanceRequest(distanceParams);
}
Expand Down
14 changes: 13 additions & 1 deletion src/libs/actions/IOU/Split.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -143,6 +145,7 @@ type CreateDistanceRequestInformation = {
previousOdometerDraft?: OnyxEntry<OnyxTypes.OdometerDraft>;
delegateAccountID: number | undefined;
isTrackIntentUser: boolean | undefined;
formatPhoneNumber: LocaleContextProps['formatPhoneNumber'];
};

type CreateSplitsTransactionParams = Omit<BaseTransactionParams, 'customUnitRateID'> & {
Expand All @@ -168,6 +171,7 @@ type CreateSplitsAndOnyxDataParams = {
participantsPolicyTags: Record<string, OnyxTypes.PolicyTagLists>;
delegateAccountID: number | undefined;
isTrackIntentUser: boolean | undefined;
formatPhoneNumber: LocaleContextProps['formatPhoneNumber'];
};

type StartSplitBilActionParams = {
Expand Down Expand Up @@ -243,6 +247,7 @@ type SplitBillActionsParams = {
shouldDeferForSearch?: boolean;
delegateAccountID: number | undefined;
isTrackIntentUser: boolean | undefined;
formatPhoneNumber: LocaleContextProps['formatPhoneNumber'];
};

/**
Expand Down Expand Up @@ -280,6 +285,7 @@ function splitBill({
shouldDeferForSearch = false,
delegateAccountID,
isTrackIntentUser,
formatPhoneNumber: formatPhoneNumberParam,
}: SplitBillActionsParams) {
const parsedComment = getParsedComment(comment);
const {splitData, splits, onyxData} = createSplitsAndOnyxData({
Expand Down Expand Up @@ -315,6 +321,7 @@ function splitBill({
participantsPolicyTags: buildParticipantsPolicyTags(participants),
delegateAccountID,
isTrackIntentUser,
formatPhoneNumber: formatPhoneNumberParam,
});

const parameters: SplitBillParams = {
Expand Down Expand Up @@ -394,6 +401,7 @@ function splitBillAndOpenReport({
shouldDeferForSearch = false,
delegateAccountID,
isTrackIntentUser,
formatPhoneNumber: formatPhoneNumberParam,
}: SplitBillActionsParams) {
const parsedComment = getParsedComment(comment);
const {splitData, splits, onyxData} = createSplitsAndOnyxData({
Expand Down Expand Up @@ -429,6 +437,7 @@ function splitBillAndOpenReport({
participantsPolicyTags: buildParticipantsPolicyTags(participants),
delegateAccountID,
isTrackIntentUser,
formatPhoneNumber: formatPhoneNumberParam,
});

const parameters: SplitBillParams = {
Expand Down Expand Up @@ -1424,6 +1433,7 @@ function createSplitsAndOnyxData({
participantsPolicyTags,
delegateAccountID,
isTrackIntentUser,
formatPhoneNumber: formatPhoneNumberParam,
}: CreateSplitsAndOnyxDataParams): SplitsAndOnyxData {
const currentUserEmailForIOUSplit = addSMSDomainIfPhoneNumber(currentUserLogin);
const participantAccountIDs = participants.map((participant) => Number(participant.accountID));
Expand Down Expand Up @@ -1806,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,
},
Expand Down Expand Up @@ -1958,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);
Expand Down Expand Up @@ -2050,6 +2061,7 @@ function createDistanceRequest(distanceRequestInformation: CreateDistanceRequest
participantsPolicyTags: buildParticipantsPolicyTags(participants),
delegateAccountID,
isTrackIntentUser,
formatPhoneNumber: formatPhoneNumberParam,
});
onyxData = splitOnyxData;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -404,6 +405,7 @@ function handleMoneyRequestStepDistanceNavigation({
},
isTrackIntentUser,
delegateAccountID,
formatPhoneNumber,
});
cleanupAfterSkipConfirmSubmit(overrides.shouldHandleNavigation, {
report,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ function useExpenseSubmission(params: UseExpenseSubmissionParams) {
} = params;

// Localization
const {translate, toLocaleDigit} = useLocalize();
const {translate, toLocaleDigit, formatPhoneNumber} = useLocalize();
const delegateAccountID = useDelegateAccountID();

// Permissions
Expand Down Expand Up @@ -797,6 +797,7 @@ function useExpenseSubmission(params: UseExpenseSubmissionParams) {
previousOdometerDraft: odometerDraft,
isTrackIntentUser,
delegateAccountID,
formatPhoneNumber,
});

const isExpenseReport = isMoneyRequestReportReportUtils(report);
Expand Down Expand Up @@ -917,6 +918,7 @@ function useExpenseSubmission(params: UseExpenseSubmissionParams) {
shouldDeferForSearch: shouldDeferSplitForSearch,
delegateAccountID,
isTrackIntentUser,
formatPhoneNumber,
});
}
markSubmitExpenseEnd();
Expand Down Expand Up @@ -956,6 +958,7 @@ function useExpenseSubmission(params: UseExpenseSubmissionParams) {
shouldDeferForSearch: shouldDeferSplitForSearch,
delegateAccountID,
isTrackIntentUser,
formatPhoneNumber,
});
}
markSubmitExpenseEnd();
Expand Down
2 changes: 2 additions & 0 deletions tests/actions/IOU/SplitReportTotalsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -507,6 +508,7 @@ describe('actions/IOU', () => {
participantsPolicyTags: overrides.participantsPolicyTags ?? {},
delegateAccountID: undefined,
isTrackIntentUser: false,
formatPhoneNumber: mockFormatPhoneNumber,
});

it('returns valid splitData with chatReportID, transactionID, and reportActionID', () => {
Expand Down
14 changes: 14 additions & 0 deletions tests/actions/IOUTest/SplitTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Comment thread
marufsharifi marked this conversation as resolved.
Outdated
jest.mock('@src/libs/SearchQueryUtils', () => {
const actual = jest.requireActual('@src/libs/SearchQueryUtils');
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
Expand Down Expand Up @@ -414,6 +415,7 @@ describe('split expense', () => {
personalDetails: mockPersonalDetails,
delegateAccountID: undefined,
isTrackIntentUser: false,
formatPhoneNumber: mockFormatPhoneNumber,
},
);
return waitForBatchedUpdates();
Expand Down Expand Up @@ -751,6 +753,7 @@ describe('split expense', () => {
personalDetails: mockPersonalDetails,
delegateAccountID: undefined,
isTrackIntentUser: false,
formatPhoneNumber: mockFormatPhoneNumber,
});

await waitForBatchedUpdates();
Expand Down Expand Up @@ -802,6 +805,7 @@ describe('split expense', () => {
personalDetails: mockPersonalDetails,
delegateAccountID: undefined,
isTrackIntentUser: false,
formatPhoneNumber: mockFormatPhoneNumber,
});

await waitForBatchedUpdates();
Expand All @@ -827,6 +831,7 @@ describe('split expense', () => {
personalDetails: mockPersonalDetails,
delegateAccountID: undefined,
isTrackIntentUser: false,
formatPhoneNumber: mockFormatPhoneNumber,
});
await waitForBatchedUpdates();

Expand Down Expand Up @@ -859,6 +864,7 @@ describe('split expense', () => {
personalDetails: mockPersonalDetails,
delegateAccountID: undefined,
isTrackIntentUser: false,
formatPhoneNumber: mockFormatPhoneNumber,
});

await waitForBatchedUpdates();
Expand Down Expand Up @@ -896,6 +902,7 @@ describe('split expense', () => {
personalDetails: mockPersonalDetails,
delegateAccountID: undefined,
isTrackIntentUser: false,
formatPhoneNumber: mockFormatPhoneNumber,
});

await waitForBatchedUpdates();
Expand All @@ -919,6 +926,7 @@ describe('split expense', () => {
personalDetails: mockPersonalDetails,
delegateAccountID: undefined,
isTrackIntentUser: false,
formatPhoneNumber: mockFormatPhoneNumber,
});

await waitForBatchedUpdates();
Expand Down Expand Up @@ -986,6 +994,7 @@ describe('split expense', () => {
personalDetails: mockPersonalDetails,
delegateAccountID: undefined,
isTrackIntentUser: false,
formatPhoneNumber: mockFormatPhoneNumber,
});

await waitForBatchedUpdates();
Expand Down Expand Up @@ -1038,6 +1047,7 @@ describe('split expense', () => {
personalDetails: mockPersonalDetails,
delegateAccountID: undefined,
isTrackIntentUser: false,
formatPhoneNumber: mockFormatPhoneNumber,
});

await waitForBatchedUpdates();
Expand Down Expand Up @@ -1101,6 +1111,7 @@ describe('split expense', () => {
personalDetails: mockPersonalDetails,
delegateAccountID: undefined,
isTrackIntentUser: false,
formatPhoneNumber: mockFormatPhoneNumber,
});

waitForBatchedUpdates();
Expand Down Expand Up @@ -1400,6 +1411,7 @@ describe('split expense', () => {
personalDetails: testPersonalDetails,
delegateAccountID: undefined,
isTrackIntentUser: false,
formatPhoneNumber: mockFormatPhoneNumber,
});

await waitForBatchedUpdates();
Expand Down Expand Up @@ -1463,6 +1475,7 @@ describe('split expense', () => {
personalDetails: participantPersonalDetails,
delegateAccountID: undefined,
isTrackIntentUser: false,
formatPhoneNumber: mockFormatPhoneNumber,
});

await waitForBatchedUpdates();
Expand Down Expand Up @@ -7619,6 +7632,7 @@ describe('createDistanceRequest', () => {
betas: [CONST.BETAS.ALL],
delegateAccountID: undefined,
isTrackIntentUser: false,
formatPhoneNumber: mockFormatPhoneNumber,
};
}

Expand Down
Loading