Skip to content

Commit

Permalink
Merge pull request #50557 from Expensify/revert-50341-georgia-heading
Browse files Browse the repository at this point in the history
[CP Staging] Revert "[ReportPreview / Text] When showing two avatars, also show both display names with tooltip"

(cherry picked from commit b70ad57)

(CP triggered by mountiny)
  • Loading branch information
lakchote authored and OSBotify committed Oct 10, 2024
1 parent b663823 commit d7ba0bf
Showing 1 changed file with 26 additions and 99 deletions.
125 changes: 26 additions & 99 deletions src/pages/home/report/ReportActionItemSingle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,40 +150,24 @@ function ReportActionItemSingle({
} else {
secondaryAvatar = {name: '', source: '', type: 'avatar'};
}
const icon = useMemo(
() => ({
source: avatarSource ?? FallbackAvatar,
type: isWorkspaceActor ? CONST.ICON_TYPE_WORKSPACE : CONST.ICON_TYPE_AVATAR,
name: primaryDisplayName ?? '',
id: avatarId,
}),
[avatarSource, isWorkspaceActor, primaryDisplayName, avatarId],
);
const icon = {
source: avatarSource ?? FallbackAvatar,
type: isWorkspaceActor ? CONST.ICON_TYPE_WORKSPACE : CONST.ICON_TYPE_AVATAR,
name: primaryDisplayName ?? '',
id: avatarId,
};

// Since the display name for a report action message is delivered with the report history as an array of fragments
// we'll need to take the displayName from personal details and have it be in the same format for now. Eventually,
// we should stop referring to the report history items entirely for this information.
const personArray = useMemo(() => {
const baseArray = displayName
? [
{
type: 'TEXT',
text: displayName,
},
]
: [action?.person?.at(0)] ?? [];

if (displayAllActors && secondaryAvatar?.name) {
return [
...baseArray,
{
type: 'TEXT',
text: secondaryAvatar?.name ?? '',
},
];
}
return baseArray;
}, [displayName, action?.person, displayAllActors, secondaryAvatar?.name]);
const personArray = displayName
? [
{
type: 'TEXT',
text: displayName,
},
]
: action?.person;

const reportID = report?.reportID;
const iouReportID = iouReport?.reportID;
Expand Down Expand Up @@ -247,74 +231,6 @@ function ReportActionItemSingle({
</UserDetailsTooltip>
);
};

const getHeading = useCallback(() => {
return () => {
if (displayAllActors && personArray.length === 2 && isReportPreviewAction) {
return (
<View style={[styles.flexRow]}>
<ReportActionItemFragment
style={[styles.flex1]}
key={`person-${action?.reportActionID}-${0}`}
accountID={actorAccountID ?? -1}
fragment={{...personArray.at(0), type: 'TEXT', text: displayName ?? ''}}
delegateAccountID={action?.delegateAccountID}
isSingleLine
actorIcon={icon}
moderationDecision={getReportActionMessage(action)?.moderationDecision?.decision}
/>
<Text
numberOfLines={1}
style={[styles.chatItemMessageHeaderSender, styles.pre]}
>
{` & `}
</Text>
<ReportActionItemFragment
style={[styles.flex1]}
key={`person-${action?.reportActionID}-${1}`}
accountID={parseInt(`${secondaryAvatar?.id ?? -1}`, 10)}
fragment={{...personArray.at(1), type: 'TEXT', text: secondaryAvatar.name ?? ''}}
delegateAccountID={action?.delegateAccountID}
isSingleLine
actorIcon={secondaryAvatar}
moderationDecision={getReportActionMessage(action)?.moderationDecision?.decision}
/>
</View>
);
}
return (
<View>
{personArray.map((fragment, index) => (
<ReportActionItemFragment
style={[styles.flex1]}
// eslint-disable-next-line react/no-array-index-key
key={`person-${action?.reportActionID}-${index}`}
accountID={actorAccountID ?? -1}
fragment={{...fragment, type: fragment?.type ?? '', text: fragment?.text ?? ''}}
delegateAccountID={action?.delegateAccountID}
isSingleLine
actorIcon={icon}
moderationDecision={getReportActionMessage(action)?.moderationDecision?.decision}
/>
))}
</View>
);
};
}, [
displayAllActors,
secondaryAvatar,
isReportPreviewAction,
personArray,
styles.flexRow,
styles.flex1,
styles.chatItemMessageHeaderSender,
styles.pre,
action,
actorAccountID,
displayName,
icon,
]);

const hasEmojiStatus = !displayAllActors && status?.emojiCode;
const formattedDate = DateUtils.getStatusUntilDate(status?.clearAfter ?? '');
const statusText = status?.text ?? '';
Expand Down Expand Up @@ -345,7 +261,18 @@ function ReportActionItemSingle({
accessibilityLabel={actorHint}
role={CONST.ROLE.BUTTON}
>
{getHeading()}
{personArray?.map((fragment, index) => (
<ReportActionItemFragment
// eslint-disable-next-line react/no-array-index-key
key={`person-${action?.reportActionID}-${index}`}
accountID={actorAccountID ?? -1}
fragment={{...fragment, type: fragment.type ?? '', text: fragment.text ?? ''}}
delegateAccountID={action?.delegateAccountID}
isSingleLine
actorIcon={icon}
moderationDecision={getReportActionMessage(action)?.moderationDecision?.decision}
/>
))}
</PressableWithoutFeedback>
{!!hasEmojiStatus && (
<Tooltip text={statusTooltipText}>
Expand Down

0 comments on commit d7ba0bf

Please sign in to comment.