Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type {OnyxEntry} from 'react-native-onyx';
import type {ValueOf} from 'type-fest';
import {FallbackAvatar} from '@components/Icon/Expensicons';
import useLocalize from '@hooks/useLocalize';
import useOnyx from '@hooks/useOnyx';
import usePolicy from '@hooks/usePolicy';
import useReportIsArchived from '@hooks/useReportIsArchived';
Expand Down Expand Up @@ -45,7 +44,6 @@ function useReportActionAvatars({
const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {
canBeMissing: true,
});
const {formatPhoneNumber} = useLocalize();

const isReportAChatReport = report?.type === CONST.REPORT.TYPE.CHAT && report?.chatType !== CONST.REPORT.CHAT_TYPE.TRIP_ROOM;

Expand Down Expand Up @@ -182,7 +180,8 @@ function useReportActionAvatars({
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
const accountID = reportPreviewSenderID || (actorAccountID ?? CONST.DEFAULT_NUMBER_ID);
const {avatar, fallbackIcon, login} = personalDetails?.[delegatePersonalDetails ? delegatePersonalDetails.accountID : accountID] ?? {};
const defaultDisplayName = getDisplayNameForParticipant({formatPhoneNumber, accountID, personalDetailsData: personalDetails}) ?? '';

const defaultDisplayName = getDisplayNameForParticipant({accountID, personalDetailsData: personalDetails}) ?? '';
const invoiceReport = [iouReport, chatReport, reportChatReport].find((susReport) => isInvoiceReport(susReport) || susReport?.chatType === CONST.REPORT.TYPE.INVOICE);
const isNestedInInvoiceReport = !!invoiceReport;
const isWorkspaceActor = isAInvoiceReport || (isAWorkspaceChat && (!actorAccountID || displayAllActors));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function MoneyRequestReportPreviewContent({
const theme = useTheme();
const styles = useThemeStyles();
const StyleUtils = useStyleUtils();
const {translate, formatPhoneNumber} = useLocalize();
const {translate} = useLocalize();
const {isOffline} = useNetwork();
const {shouldUseNarrowLayout} = useResponsiveLayout();

Expand Down Expand Up @@ -249,7 +249,7 @@ function MoneyRequestReportPreviewContent({
} else if (isInvoiceRoom) {
payerOrApproverName = getInvoicePayerName(chatReport, invoiceReceiverPolicy, invoiceReceiverPersonalDetail);
} else {
payerOrApproverName = getDisplayNameForParticipant({accountID: managerID, shouldUseShortForm: true, formatPhoneNumber});
payerOrApproverName = getDisplayNameForParticipant({accountID: managerID, shouldUseShortForm: true});
}

if (isApproved) {
Expand All @@ -260,7 +260,7 @@ function MoneyRequestReportPreviewContent({
paymentVerb = 'iou.payerPaid';
} else if (hasNonReimbursableTransactions) {
paymentVerb = 'iou.payerSpent';
payerOrApproverName = getDisplayNameForParticipant({accountID: chatReport?.ownerAccountID, shouldUseShortForm: true, formatPhoneNumber});
payerOrApproverName = getDisplayNameForParticipant({accountID: chatReport?.ownerAccountID, shouldUseShortForm: true});
}
return translate(paymentVerb, {payer: payerOrApproverName});
}, [
Expand All @@ -282,7 +282,6 @@ function MoneyRequestReportPreviewContent({
invoiceReceiverPolicy,
invoiceReceiverPersonalDetail,
managerID,
formatPhoneNumber,
]);

/*
Expand Down
4 changes: 2 additions & 2 deletions src/components/ReportActionItem/TaskView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ type TaskViewProps = {
};

function TaskView({report, parentReport, action}: TaskViewProps) {
const {translate, localeCompare, formatPhoneNumber} = useLocalize();
const {translate, localeCompare} = useLocalize();
const styles = useThemeStyles();
const StyleUtils = useStyleUtils();
const currentUserPersonalDetails = useCurrentUserPersonalDetails();
Expand Down Expand Up @@ -178,7 +178,7 @@ function TaskView({report, parentReport, action}: TaskViewProps) {
{report?.managerID ? (
<MenuItem
label={translate('task.assignee')}
title={getDisplayNameForParticipant({formatPhoneNumber, accountID: report.managerID})}
title={getDisplayNameForParticipant({accountID: report.managerID})}
iconAccountID={report.managerID}
iconType={CONST.ICON_TYPE_AVATAR}
avatarSize={CONST.AVATAR_SIZE.SMALLER}
Expand Down
5 changes: 2 additions & 3 deletions src/components/Search/SearchFiltersParticipantsSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type SearchFiltersParticipantsSelectorProps = {
};

function SearchFiltersParticipantsSelector({initialAccountIDs, onFiltersUpdate}: SearchFiltersParticipantsSelectorProps) {
const {translate, formatPhoneNumber} = useLocalize();
const {translate} = useLocalize();
const personalDetails = usePersonalDetails();
const {didScreenTransitionEnd} = useScreenWrapperTransitionStatus();
const {options, areOptionsInitialized} = useOptionsList({
Expand Down Expand Up @@ -118,7 +118,6 @@ function SearchFiltersParticipantsSelector({initialAccountIDs, onFiltersUpdate}:
// If the current user is not selected, add them to the top of the list
if (!selectedCurrentUser && chatOptions.currentUserOption) {
const formattedName = getDisplayNameForParticipant({
formatPhoneNumber,
accountID: chatOptions.currentUserOption.accountID,
shouldAddCurrentUserPostfix: true,
personalDetailsData: personalDetails,
Expand Down Expand Up @@ -153,7 +152,7 @@ function SearchFiltersParticipantsSelector({initialAccountIDs, onFiltersUpdate}:
sections: newSections,
headerMessage: message,
};
}, [areOptionsInitialized, cleanSearchTerm, selectedOptions, chatOptions, personalDetails, reportAttributesDerived, translate, formatPhoneNumber]);
}, [areOptionsInitialized, cleanSearchTerm, selectedOptions, chatOptions, personalDetails, reportAttributesDerived, translate]);

const resetChanges = useCallback(() => {
setSelectedOptions([]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import BaseListItem from '@components/SelectionList/BaseListItem';
import type {ListItem, UserSelectionListItemProps} from '@components/SelectionList/types';
import TextWithTooltip from '@components/TextWithTooltip';
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
import useLocalize from '@hooks/useLocalize';
import useStyleUtils from '@hooks/useStyleUtils';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
Expand Down Expand Up @@ -37,7 +36,7 @@ function UserSelectionListItem<TItem extends ListItem>({
const theme = useTheme();
const StyleUtils = useStyleUtils();
const currentUserPersonalDetails = useCurrentUserPersonalDetails();
const {formatPhoneNumber} = useLocalize();

const handleCheckboxPress = useCallback(() => {
if (onCheckboxPress) {
onCheckboxPress(item);
Expand All @@ -60,10 +59,9 @@ function UserSelectionListItem<TItem extends ListItem>({

const userDisplayName = useMemo(() => {
return getDisplayNameForParticipant({
formatPhoneNumber,
accountID: item.accountID ?? CONST.DEFAULT_NUMBER_ID,
});
}, [item.accountID, formatPhoneNumber]);
}, [item.accountID]);

return (
<BaseListItem
Expand Down
10 changes: 4 additions & 6 deletions src/libs/NextStepUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import type {Message} from '@src/types/onyx/ReportNextStep';
import type DeepValueOf from '@src/types/utils/DeepValueOf';
import EmailUtils from './EmailUtils';
import {formatPhoneNumber} from './LocalePhoneNumber';
import Permissions from './Permissions';
import {getLoginsByAccountIDs, getPersonalDetailsByIDs} from './PersonalDetailsUtils';
import {getApprovalWorkflow, getCorrectedAutoReportingFrequency, getReimburserAccountID} from './PolicyUtils';
Expand All @@ -30,7 +29,7 @@

let currentUserAccountID = -1;
let currentUserEmail = '';
Onyx.connect({

Check warning on line 32 in src/libs/NextStepUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.SESSION,
callback: (value) => {
if (!value) {
Expand All @@ -43,20 +42,20 @@
});

let allPolicies: OnyxCollection<Policy>;
Onyx.connect({

Check warning on line 45 in src/libs/NextStepUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.POLICY,
waitForCollectionCallback: true,
callback: (value) => (allPolicies = value),
});

let allBetas: OnyxEntry<Beta[]>;
Onyx.connect({

Check warning on line 52 in src/libs/NextStepUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.BETAS,
callback: (value) => (allBetas = value),
});

let transactionViolations: OnyxCollection<TransactionViolations>;
Onyx.connect({

Check warning on line 58 in src/libs/NextStepUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS,
waitForCollectionCallback: true,
callback: (value) => {
Expand Down Expand Up @@ -98,7 +97,7 @@
function getNextApproverDisplayName(report: OnyxEntry<Report>, isUnapprove?: boolean) {
const approverAccountID = getNextApproverAccountID(report, isUnapprove);

return getDisplayNameForParticipant({formatPhoneNumber, accountID: approverAccountID}) ?? getPersonalDetailsForAccountID(approverAccountID).login;
return getDisplayNameForParticipant({accountID: approverAccountID}) ?? getPersonalDetailsForAccountID(approverAccountID).login;
}

function buildOptimisticNextStepForPreventSelfApprovalsEnabled() {
Expand Down Expand Up @@ -217,9 +216,8 @@
(report.unheldNonReimbursableTotal !== 0 && report.unheldNonReimbursableTotal !== undefined));
const {reimbursableSpend} = getMoneyRequestSpendBreakdown(report);

const ownerDisplayName = ownerPersonalDetails?.displayName ?? ownerPersonalDetails?.login ?? getDisplayNameForParticipant({formatPhoneNumber, accountID: ownerAccountID});
const policyOwnerDisplayName =
policyOwnerPersonalDetails?.displayName ?? policyOwnerPersonalDetails?.login ?? getDisplayNameForParticipant({formatPhoneNumber, accountID: policy.ownerAccountID});
const ownerDisplayName = ownerPersonalDetails?.displayName ?? ownerPersonalDetails?.login ?? getDisplayNameForParticipant({accountID: ownerAccountID});
const policyOwnerDisplayName = policyOwnerPersonalDetails?.displayName ?? policyOwnerPersonalDetails?.login ?? getDisplayNameForParticipant({accountID: policy.ownerAccountID});
const nextApproverDisplayName = getNextApproverDisplayName(report, isUnapprove);
const approverAccountID = getNextApproverAccountID(report, isUnapprove);
const approvers = getLoginsByAccountIDs([approverAccountID ?? CONST.DEFAULT_NUMBER_ID]);
Expand Down Expand Up @@ -527,7 +525,7 @@
text: 'an admin',
}
: {
text: getDisplayNameForParticipant({formatPhoneNumber, accountID: reimburserAccountID}),
text: getDisplayNameForParticipant({accountID: reimburserAccountID}),
type: 'strong',
},
{
Expand Down
4 changes: 2 additions & 2 deletions src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@
*/
let currentUserLogin: string | undefined;
let currentUserAccountID: number | undefined;
Onyx.connect({

Check warning on line 341 in src/libs/OptionsListUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.SESSION,
callback: (value) => {
currentUserLogin = value?.email;
Expand All @@ -347,19 +347,19 @@
});

let loginList: OnyxEntry<Login>;
Onyx.connect({

Check warning on line 350 in src/libs/OptionsListUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.LOGIN_LIST,
callback: (value) => (loginList = isEmptyObject(value) ? {} : value),
});

let allPersonalDetails: OnyxEntry<PersonalDetailsList>;
Onyx.connect({

Check warning on line 356 in src/libs/OptionsListUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
callback: (value) => (allPersonalDetails = isEmptyObject(value) ? {} : value),
});

const policies: OnyxCollection<Policy> = {};
Onyx.connect({

Check warning on line 362 in src/libs/OptionsListUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.POLICY,
callback: (policy, key) => {
if (!policy || !key || !policy.name) {
Expand All @@ -371,14 +371,14 @@
});

let allPolicies: OnyxCollection<Policy> = {};
Onyx.connect({

Check warning on line 374 in src/libs/OptionsListUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.POLICY,
waitForCollectionCallback: true,
callback: (val) => (allPolicies = val),
});

let allReports: OnyxCollection<Report>;
Onyx.connect({

Check warning on line 381 in src/libs/OptionsListUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
callback: (value) => {
Expand Down Expand Up @@ -1004,11 +1004,11 @@
result.alternateText = showPersonalDetails && personalDetail?.login ? personalDetail.login : getAlternateText(result, {showChatPreviewLine, forcePolicyNamePreview});

reportName = showPersonalDetails
? getDisplayNameForParticipant({formatPhoneNumber, accountID: accountIDs.at(0)}) || formatPhoneNumber(personalDetail?.login ?? '')
? getDisplayNameForParticipant({accountID: accountIDs.at(0)}) || formatPhoneNumber(personalDetail?.login ?? '')
: getReportName(report, undefined, undefined, undefined, undefined, undefined, transactions);
} else {
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
reportName = getDisplayNameForParticipant({formatPhoneNumber, accountID: accountIDs.at(0)}) || formatPhoneNumber(personalDetail?.login ?? '');
reportName = getDisplayNameForParticipant({accountID: accountIDs.at(0)}) || formatPhoneNumber(personalDetail?.login ?? '');
result.keyForList = String(accountIDs.at(0));

result.alternateText = formatPhoneNumber(personalDetails?.[accountIDs[0]]?.login ?? '');
Expand Down
Loading
Loading