Skip to content

Commit

Permalink
Merge pull request #34213 from dukenv0307/fix/33740
Browse files Browse the repository at this point in the history
  • Loading branch information
cead22 authored Feb 28, 2024
2 parents e6c5cc4 + 0b8d0d0 commit 5d737d0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/components/MultipleAvatars.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type {ValueOf} from 'type-fest';
import useStyleUtils from '@hooks/useStyleUtils';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import * as ReportUtils from '@libs/ReportUtils';
import type {AvatarSource} from '@libs/UserUtils';
import variables from '@styles/variables';
import CONST from '@src/CONST';
Expand Down Expand Up @@ -106,7 +107,8 @@ function MultipleAvatars({
let avatarContainerStyles = StyleUtils.getContainerStyles(size, isInReportAction);
const {singleAvatarStyle, secondAvatarStyles} = useMemo(() => avatarSizeToStylesMap[size as AvatarSizeToStyles] ?? avatarSizeToStylesMap.default, [size, avatarSizeToStylesMap]);

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

const avatarSize = useMemo(() => {
if (isFocusMode) {
return CONST.AVATAR_SIZE.MID_SUBSCRIPT;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function BaseUserDetailsTooltip({accountID, fallbackUserDetails, icon, delegateA
const personalDetails = usePersonalDetails();

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

let userAvatar = userDetails.avatar;
Expand All @@ -29,7 +29,7 @@ function BaseUserDetailsTooltip({accountID, fallbackUserDetails, icon, delegateA
// the Copilot feature is implemented.
if (delegateAccountID) {
const delegateUserDetails = personalDetails?.[delegateAccountID];
const delegateUserDisplayName = ReportUtils.getDisplayNameForParticipant(delegateAccountID);
const delegateUserDisplayName = ReportUtils.getUserDetailTooltipText(delegateAccountID);
userDisplayName = `${delegateUserDisplayName} (${translate('reportAction.asCopilot')} ${userDisplayName})`;
userLogin = delegateUserDetails?.login ?? '';
userAvatar = delegateUserDetails?.avatar;
Expand Down
9 changes: 9 additions & 0 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1697,6 +1697,14 @@ function getDisplayNamesWithTooltips(
});
}

/**
* Returns the the display names of the given user accountIDs
*/
function getUserDetailTooltipText(accountID: number, fallbackUserDisplayName = ''): string {
const displayNameForParticipant = getDisplayNameForParticipant(accountID);
return displayNameForParticipant || fallbackUserDisplayName;
}

/**
* For a deleted parent report action within a chat report,
* let us return the appropriate display message
Expand Down Expand Up @@ -5193,6 +5201,7 @@ export {
buildOptimisticUnHoldReportAction,
shouldDisplayThreadReplies,
shouldDisableThread,
getUserDetailTooltipText,
doesReportBelongToWorkspace,
getChildReportNotificationPreference,
getAllAncestorReportActions,
Expand Down

0 comments on commit 5d737d0

Please sign in to comment.