Skip to content
13 changes: 10 additions & 3 deletions src/components/ReportActionAvatars/ReportActionAvatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ function ReportActionAvatarMultipleHorizontal({
const theme = useTheme();
const styles = useThemeStyles();
const StyleUtils = useStyleUtils();
const {localeCompare} = useLocalize();
const {localeCompare, formatPhoneNumber} = useLocalize();

const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {
canBeMissing: true,
Expand Down Expand Up @@ -368,7 +368,10 @@ function ReportActionAvatarMultipleHorizontal({
return [firstRow, secondRow];
}, [icons, maxAvatarsInRow, shouldDisplayAvatarsInRows]);

const tooltipTexts = useMemo(() => (shouldShowTooltip ? icons.map((icon) => getUserDetailTooltipText(Number(icon.id), icon.name)) : ['']), [shouldShowTooltip, icons]);
const tooltipTexts = useMemo(
() => (shouldShowTooltip ? icons.map((icon) => getUserDetailTooltipText(Number(icon.id), formatPhoneNumber, icon.name)) : ['']),
[shouldShowTooltip, icons, formatPhoneNumber],
);

return avatarRows.map((avatars, rowIndex) => (
<View
Expand Down Expand Up @@ -478,8 +481,12 @@ function ReportActionAvatarMultipleDiagonal({
const theme = useTheme();
const styles = useThemeStyles();
const StyleUtils = useStyleUtils();
const {formatPhoneNumber} = useLocalize();

const tooltipTexts = useMemo(() => (shouldShowTooltip ? icons.map((icon) => getUserDetailTooltipText(Number(icon.id), icon.name)) : ['']), [shouldShowTooltip, icons]);
const tooltipTexts = useMemo(
() => (shouldShowTooltip ? icons.map((icon) => getUserDetailTooltipText(Number(icon.id), formatPhoneNumber, icon.name)) : ['']),
[shouldShowTooltip, icons, formatPhoneNumber],
);
const removeRightMargin = icons.length === 2 && size === CONST.AVATAR_SIZE.X_LARGE;
const avatarContainerStyles = StyleUtils.getContainerStyles(size, isInReportAction);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {Str} from 'expensify-common';
import React, {useCallback} from 'react';
import {View} from 'react-native';
import Avatar from '@components/Avatar';
Expand All @@ -22,8 +21,8 @@ function BaseUserDetailsTooltip({accountID, fallbackUserDetails, icon, delegateA
const isCurrentUserAnonymous = session?.accountID === accountID && isAnonymousUser(session);

const userDetails = personalDetails?.[accountID] ?? fallbackUserDetails ?? {};
let userDisplayName = getUserDetailTooltipText(accountID, userDetails.displayName ? userDetails.displayName.trim() : '');
let userLogin = !isCurrentUserAnonymous && userDetails.login?.trim() && userDetails.login !== userDetails.displayName ? Str.removeSMSDomain(userDetails.login) : '';
let userDisplayName = getUserDetailTooltipText(accountID, formatPhoneNumber, userDetails.displayName ? userDetails.displayName.trim() : '');
let userLogin = !isCurrentUserAnonymous && userDetails.login?.trim() && userDetails.login !== userDetails.displayName ? formatPhoneNumber(userDetails.login) : '';

let userAvatar = userDetails.avatar;
let userAccountID = accountID;
Expand All @@ -32,15 +31,15 @@ function BaseUserDetailsTooltip({accountID, fallbackUserDetails, icon, delegateA
// the Copilot feature is implemented.
if (delegateAccountID && delegateAccountID > 0) {
const delegateUserDetails = personalDetails?.[delegateAccountID];
const delegateUserDisplayName = getUserDetailTooltipText(delegateAccountID);
const delegateUserDisplayName = getUserDetailTooltipText(delegateAccountID, formatPhoneNumber);
userDisplayName = `${delegateUserDisplayName} (${translate('reportAction.asCopilot')} ${userDisplayName})`;
userLogin = delegateUserDetails?.login ?? '';
userAvatar = delegateUserDetails?.avatar;
userAccountID = delegateAccountID;
}

let title = String(userDisplayName).trim() ? userDisplayName : '';
let subtitle = userLogin.trim() && formatPhoneNumber(userLogin) !== userDisplayName ? Str.removeSMSDomain(userLogin) : '';
let subtitle = userLogin.trim() && formatPhoneNumber(userLogin) !== userDisplayName ? formatPhoneNumber(userLogin) : '';
if (icon && (icon.type === CONST.ICON_TYPE_WORKSPACE || !title)) {
title = icon.name ?? '';

Expand Down
2 changes: 1 addition & 1 deletion src/libs/OptionsListUtils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@
*/
let currentUserLogin: string | undefined;
let currentUserAccountID: number | undefined;
Onyx.connect({

Check warning on line 193 in src/libs/OptionsListUtils/index.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 @@ -199,13 +199,13 @@
});

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

Check warning on line 202 in src/libs/OptionsListUtils/index.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 208 in src/libs/OptionsListUtils/index.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 @@ -217,14 +217,14 @@
});

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

Check warning on line 220 in src/libs/OptionsListUtils/index.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 227 in src/libs/OptionsListUtils/index.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 All @@ -233,7 +233,7 @@
});

let allReportNameValuePairs: OnyxCollection<ReportNameValuePairs>;
Onyx.connect({

Check warning on line 236 in src/libs/OptionsListUtils/index.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_NAME_VALUE_PAIRS,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -245,7 +245,7 @@
const allSortedReportActions: Record<string, ReportAction[]> = {};
let allReportActions: OnyxCollection<ReportActions>;
const lastVisibleReportActions: ReportActions = {};
Onyx.connect({

Check warning on line 248 in src/libs/OptionsListUtils/index.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_ACTIONS,
waitForCollectionCallback: true,
callback: (actions) => {
Expand Down Expand Up @@ -307,7 +307,7 @@
});

let activePolicyID: OnyxEntry<string>;
Onyx.connect({

Check warning on line 310 in src/libs/OptionsListUtils/index.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.NVP_ACTIVE_POLICY_ID,
callback: (value) => (activePolicyID = value),
});
Expand Down Expand Up @@ -669,7 +669,7 @@
lastMessageTextFromReport = formatReportLastMessageText(Parser.htmlToText(reportPreviewMessage));
}
} else if (isReimbursementQueuedAction(lastReportAction)) {
lastMessageTextFromReport = getReimbursementQueuedActionMessage({reportAction: lastReportAction, reportOrID: report});
lastMessageTextFromReport = getReimbursementQueuedActionMessage({reportAction: lastReportAction, formatPhoneNumber: formatPhoneNumberPhoneUtils, reportOrID: report});
} else if (isReimbursementDeQueuedOrCanceledAction(lastReportAction)) {
lastMessageTextFromReport = getReimbursementDeQueuedOrCanceledActionMessage(lastReportAction, report);
} else if (isDeletedParentAction(lastReportAction) && reportUtilsIsChatReport(report)) {
Expand Down
12 changes: 9 additions & 3 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3932,8 +3932,8 @@ function getDisplayNamesWithTooltips(
/**
* Returns the the display names of the given user accountIDs
*/
function getUserDetailTooltipText(accountID: number, fallbackUserDisplayName = ''): string {
const displayNameForParticipant = getDisplayNameForParticipant({accountID, formatPhoneNumber: formatPhoneNumberPhoneUtils});
function getUserDetailTooltipText(accountID: number, formatPhoneNumber: LocaleContextProps['formatPhoneNumber'], fallbackUserDisplayName = ''): string {
const displayNameForParticipant = getDisplayNameForParticipant({accountID, formatPhoneNumber});
return displayNameForParticipant || fallbackUserDisplayName;
}

Expand Down Expand Up @@ -3961,12 +3961,14 @@ function getDeletedParentActionMessageForChatReport(reportAction: OnyxEntry<Repo
function getReimbursementQueuedActionMessage({
reportAction,
reportOrID,
formatPhoneNumber,
shouldUseShortDisplayName = true,
reports,
personalDetails,
}: {
reportAction: OnyxEntry<ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_QUEUED>>;
reportOrID: OnyxEntry<Report> | string;
formatPhoneNumber: LocaleContextProps['formatPhoneNumber'];
shouldUseShortDisplayName?: boolean;
reports?: Report[];
personalDetails?: Partial<PersonalDetailsList>;
Expand All @@ -3977,7 +3979,7 @@ function getReimbursementQueuedActionMessage({
accountID: report?.ownerAccountID,
shouldUseShortForm: shouldUseShortDisplayName,
personalDetailsData: personalDetails,
formatPhoneNumber: formatPhoneNumberPhoneUtils,
formatPhoneNumber,
}) ?? '';
const originalMessage = getOriginalMessage(reportAction);
let messageKey: TranslationPaths;
Expand Down Expand Up @@ -5620,12 +5622,14 @@ function parseReportActionHtmlToText(reportAction: OnyxEntry<ReportAction>, repo
*/
function getReportActionMessage({
reportAction,
formatPhoneNumber,
reportID,
childReportID,
reports,
personalDetails,
}: {
reportAction: OnyxEntry<ReportAction>;
formatPhoneNumber: LocaleContextProps['formatPhoneNumber'];
reportID?: string;
childReportID?: string;
reports?: Report[];
Expand Down Expand Up @@ -5665,6 +5669,7 @@ function getReportActionMessage({
return getReimbursementQueuedActionMessage({
reportAction,
reportOrID: getReportOrDraftReport(reportID, reports),
formatPhoneNumber,
shouldUseShortDisplayName: false,
reports,
personalDetails,
Expand Down Expand Up @@ -6040,6 +6045,7 @@ function getReportName(
const isAttachment = isReportActionAttachment(!isEmptyObject(parentReportAction) ? parentReportAction : undefined);
const reportActionMessage = getReportActionMessage({
reportAction: parentReportAction,
formatPhoneNumber: formatPhoneNumberPhoneUtils,
reportID: report?.parentReportID,
childReportID: report?.reportID,
reports,
Expand Down
5 changes: 4 additions & 1 deletion src/pages/home/report/ContextMenu/ContextMenuActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import EmailUtils from '@libs/EmailUtils';
import {getEnvironmentURL} from '@libs/Environment/Environment';
import fileDownload from '@libs/fileDownload';
import getAttachmentDetails from '@libs/fileDownload/getAttachmentDetails';
import {formatPhoneNumber as formatPhoneNumberPhoneUtils} from '@libs/LocalePhoneNumber';
import {getForReportActionTemp} from '@libs/ModifiedExpenseMessage';
import Navigation from '@libs/Navigation/Navigation';
import Parser from '@libs/Parser';
Expand Down Expand Up @@ -756,7 +757,9 @@ const ContextMenuActions: ContextMenuAction[] = [
} else if (isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.MARKED_REIMBURSED)) {
Clipboard.setString(translate('iou.paidElsewhere'));
} else if (isReimbursementQueuedAction(reportAction)) {
Clipboard.setString(getReimbursementQueuedActionMessage({reportAction, reportOrID: reportID, shouldUseShortDisplayName: false}));
Clipboard.setString(
getReimbursementQueuedActionMessage({reportAction, formatPhoneNumber: formatPhoneNumberPhoneUtils, reportOrID: reportID, shouldUseShortDisplayName: false}),
);
} else if (isActionableMentionWhisper(reportAction)) {
const mentionWhisperMessage = getActionableMentionWhisperMessage(reportAction);
setClipboardMessage(mentionWhisperMessage);
Expand Down
Loading