Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
4 changes: 4 additions & 0 deletions src/hooks/useDeleteTransactions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import {useSearchQueryContext, useSearchResultsContext} from '@components/Search/SearchContext';

import useLocalize from '@hooks/useLocalize';

Check failure on line 3 in src/hooks/useDeleteTransactions.ts

View workflow job for this annotation

GitHub Actions / ESLint check

Unexpected subpath import via alias '@hooks/useLocalize'. Use './useLocalize' instead

import {deleteMoneyRequest} from '@libs/actions/IOU/DeleteMoneyRequest';
import {getIOUActionForTransactions} from '@libs/actions/IOU/Duplicate';
import {getIOURequestPolicyID} from '@libs/actions/IOU/MoneyRequest';
Expand Down Expand Up @@ -71,6 +73,7 @@
* 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);
Expand Down Expand Up @@ -323,6 +326,7 @@
expenseReport,
isOffline,
isTrackIntentUser,
formatPhoneNumber,
});
}

Expand Down Expand Up @@ -367,7 +371,7 @@
deletedTransactionThreadReportIDs: Array.from(deletedTransactionThreadReportIDs),
};
},
[

Check failure on line 374 in src/hooks/useDeleteTransactions.ts

View workflow job for this annotation

GitHub Actions / ESLint check

React Hook useCallback has a missing dependency: 'formatPhoneNumber'. Either include it or remove the dependency array
allPolicyRecentlyUsedCategories,
allReportNameValuePairs,
allReports,
Expand Down
8 changes: 6 additions & 2 deletions src/libs/actions/IOU/MoneyRequestBuilder.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -225,6 +226,7 @@ type MoneyRequestInformationParams = {
personalDetails: OnyxEntry<OnyxTypes.PersonalDetailsList>;
isTrackIntentUser: boolean | undefined;
delegateAccountID: number | undefined;
formatPhoneNumber?: LocaleContextProps['formatPhoneNumber'];
Comment thread
marufsharifi marked this conversation as resolved.
Outdated
};

type MoneyRequestOptimisticParams = {
Expand Down Expand Up @@ -1291,7 +1293,9 @@ function getMoneyRequestInformation(moneyRequestInformation: MoneyRequestInforma
betas,
delegateAccountID,
isTrackIntentUser,
formatPhoneNumber,
} = moneyRequestInformation;
const formatPhone = formatPhoneNumber ?? ((n: string) => n);
Comment thread
marufsharifi marked this conversation as resolved.
Outdated
const {payeeAccountID = currentUserAccountIDParam, payeeEmail = currentUserEmailParam, participant} = participantParams;
const {policy, policyCategories, policyTagList, policyRecentlyUsedCategories, policyRecentlyUsedTags} = policyParams;

Expand Down Expand Up @@ -1614,7 +1618,7 @@ function getMoneyRequestInformation(moneyRequestInformation: MoneyRequestInforma
? {
[payerAccountID]: {
accountID: payerAccountID,
displayName: formatPhoneNumber(optimisticPersonalDetailDisplayName),
displayName: formatPhone(optimisticPersonalDetailDisplayName),
firstName: optimisticPersonalDetailFirstName,
lastName: optimisticPersonalDetailLastName,
login: participant.login,
Expand Down
11 changes: 9 additions & 2 deletions src/libs/actions/IOU/PerDiem.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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';
Expand Down Expand Up @@ -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 = {
Expand All @@ -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 = {
Expand Down Expand Up @@ -324,7 +327,9 @@ function getPerDiemExpenseInformation(perDiemExpenseInformation: PerDiemExpenseI
optimisticTransactionID: uiProvidedOptimisticTransactionID,
delegateAccountID,
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;
Expand Down Expand Up @@ -499,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,
},
Expand Down Expand Up @@ -932,6 +937,7 @@ function submitPerDiemExpense(submitPerDiemExpenseInformation: PerDiemExpenseInf
optimisticTransactionID,
delegateAccountID,
isTrackIntentUser,
formatPhoneNumber,
} = submitPerDiemExpenseInformation;
const {currency, comment = '', category, tag, created, customUnit, attendees, isFromGlobalCreate} = transactionParams;

Expand Down Expand Up @@ -985,6 +991,7 @@ function submitPerDiemExpense(submitPerDiemExpenseInformation: PerDiemExpenseInf
optimisticTransactionID,
delegateAccountID,
isTrackIntentUser,
formatPhoneNumber,
});

const activeReportID = isMoneyRequestReport && Navigation.getTopmostReportId() === report?.reportID ? report?.reportID : chatReport.reportID;
Expand Down
10 changes: 8 additions & 2 deletions src/libs/actions/IOU/SendInvoice.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -87,6 +88,7 @@ type SendInvoiceOptions = {
senderPolicyTags: OnyxEntry<OnyxTypes.PolicyTagLists>;
// 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 = {
Expand Down Expand Up @@ -591,7 +593,9 @@ function getSendInvoiceInformation({
policyRecentlyUsedTags,
senderPolicyTags,
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;
Expand Down Expand Up @@ -660,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,
};
Expand Down Expand Up @@ -740,6 +744,7 @@ function sendInvoice({
isFromGlobalCreate = false,
senderPolicyTags,
delegateAccountID,
formatPhoneNumber,
}: SendInvoiceOptions) {
const parsedComment = getParsedComment(transaction?.comment?.comment?.trim() ?? '');
if (transaction?.comment) {
Expand Down Expand Up @@ -775,6 +780,7 @@ function sendInvoice({
policyRecentlyUsedTags,
senderPolicyTags: senderPolicyTags ?? {},
delegateAccountID,
formatPhoneNumber,
});

const parameters: SendInvoiceParams = {
Expand Down
22 changes: 19 additions & 3 deletions src/libs/actions/IOU/Split.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
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';
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';
Expand Down Expand Up @@ -143,6 +144,7 @@ type CreateDistanceRequestInformation = {
previousOdometerDraft?: OnyxEntry<OnyxTypes.OdometerDraft>;
delegateAccountID: number | undefined;
isTrackIntentUser: boolean | undefined;
formatPhoneNumber?: LocaleContextProps['formatPhoneNumber'];
};

type CreateSplitsTransactionParams = Omit<BaseTransactionParams, 'customUnitRateID'> & {
Expand All @@ -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 = {
Expand All @@ -194,6 +197,7 @@ type StartSplitBilActionParams = {
quickAction: OnyxEntry<OnyxTypes.QuickAction>;
policyRecentlyUsedCurrencies: string[];
participantsPolicyTags: Record<string, OnyxTypes.PolicyTagLists>;
formatPhoneNumber?: LocaleContextProps['formatPhoneNumber'];
};

type SplitBillActionsParams = {
Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -280,6 +285,7 @@ function splitBill({
shouldDeferForSearch = false,
delegateAccountID,
isTrackIntentUser,
formatPhoneNumber,
}: 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,
});

const parameters: SplitBillParams = {
Expand Down Expand Up @@ -394,6 +401,7 @@ function splitBillAndOpenReport({
shouldDeferForSearch = false,
delegateAccountID,
isTrackIntentUser,
formatPhoneNumber,
}: 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,
});

const parameters: SplitBillParams = {
Expand Down Expand Up @@ -501,7 +510,9 @@ function startSplitBill({
participantsPolicyTags,
shouldHandleNavigation = true,
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);
Expand Down Expand Up @@ -760,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,
Expand Down Expand Up @@ -1425,7 +1436,9 @@ function createSplitsAndOnyxData({
participantsPolicyTags,
delegateAccountID,
isTrackIntentUser,
formatPhoneNumber,
}: CreateSplitsAndOnyxDataParams): SplitsAndOnyxData {
const formatPhone = formatPhoneNumber ?? ((n: string) => n);
const currentUserEmailForIOUSplit = addSMSDomainIfPhoneNumber(currentUserLogin);
const participantAccountIDs = participants.map((participant) => Number(participant.accountID));

Expand Down Expand Up @@ -1807,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,
},
Expand Down Expand Up @@ -1959,6 +1972,7 @@ function createDistanceRequest(distanceRequestInformation: CreateDistanceRequest
previousOdometerDraft,
delegateAccountID,
isTrackIntentUser,
formatPhoneNumber,
} = distanceRequestInformation;
const {policy, policyCategories, policyTagList, policyRecentlyUsedCategories, policyRecentlyUsedTags} = policyParams;
const parsedComment = getParsedComment(transactionParams.comment);
Expand Down Expand Up @@ -2051,6 +2065,7 @@ function createDistanceRequest(distanceRequestInformation: CreateDistanceRequest
participantsPolicyTags: buildParticipantsPolicyTags(participants),
delegateAccountID,
isTrackIntentUser,
formatPhoneNumber,
});
onyxData = splitOnyxData;

Expand Down Expand Up @@ -2144,6 +2159,7 @@ function createDistanceRequest(distanceRequestInformation: CreateDistanceRequest
optimisticReportPreviewActionID,
delegateAccountID,
isTrackIntentUser,
formatPhoneNumber,
});

onyxData = moneyRequestOnyxData;
Expand Down
4 changes: 4 additions & 0 deletions src/libs/actions/IOU/SplitTransactionUpdate.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -108,6 +109,7 @@ type UpdateSplitTransactionsParams = {
expenseReport: OnyxEntry<OnyxTypes.Report>;
isOffline: boolean;
isTrackIntentUser: boolean | undefined;
formatPhoneNumber?: LocaleContextProps['formatPhoneNumber'];
};

function updateSplitTransactions({
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<UpdateMoneyRequestDataKeys> = {};
Expand Down
Loading
Loading