Skip to content

Commit d7ba0bf

Browse files
lakchoteOSBotify
authored andcommitted
Merge pull request #50557 from Expensify/revert-50341-georgia-heading
[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)
1 parent b663823 commit d7ba0bf

File tree

1 file changed

+26
-99
lines changed

1 file changed

+26
-99
lines changed

src/pages/home/report/ReportActionItemSingle.tsx

+26-99
Original file line numberDiff line numberDiff line change
@@ -150,40 +150,24 @@ function ReportActionItemSingle({
150150
} else {
151151
secondaryAvatar = {name: '', source: '', type: 'avatar'};
152152
}
153-
const icon = useMemo(
154-
() => ({
155-
source: avatarSource ?? FallbackAvatar,
156-
type: isWorkspaceActor ? CONST.ICON_TYPE_WORKSPACE : CONST.ICON_TYPE_AVATAR,
157-
name: primaryDisplayName ?? '',
158-
id: avatarId,
159-
}),
160-
[avatarSource, isWorkspaceActor, primaryDisplayName, avatarId],
161-
);
153+
const icon = {
154+
source: avatarSource ?? FallbackAvatar,
155+
type: isWorkspaceActor ? CONST.ICON_TYPE_WORKSPACE : CONST.ICON_TYPE_AVATAR,
156+
name: primaryDisplayName ?? '',
157+
id: avatarId,
158+
};
162159

163160
// Since the display name for a report action message is delivered with the report history as an array of fragments
164161
// we'll need to take the displayName from personal details and have it be in the same format for now. Eventually,
165162
// we should stop referring to the report history items entirely for this information.
166-
const personArray = useMemo(() => {
167-
const baseArray = displayName
168-
? [
169-
{
170-
type: 'TEXT',
171-
text: displayName,
172-
},
173-
]
174-
: [action?.person?.at(0)] ?? [];
175-
176-
if (displayAllActors && secondaryAvatar?.name) {
177-
return [
178-
...baseArray,
179-
{
180-
type: 'TEXT',
181-
text: secondaryAvatar?.name ?? '',
182-
},
183-
];
184-
}
185-
return baseArray;
186-
}, [displayName, action?.person, displayAllActors, secondaryAvatar?.name]);
163+
const personArray = displayName
164+
? [
165+
{
166+
type: 'TEXT',
167+
text: displayName,
168+
},
169+
]
170+
: action?.person;
187171

188172
const reportID = report?.reportID;
189173
const iouReportID = iouReport?.reportID;
@@ -247,74 +231,6 @@ function ReportActionItemSingle({
247231
</UserDetailsTooltip>
248232
);
249233
};
250-
251-
const getHeading = useCallback(() => {
252-
return () => {
253-
if (displayAllActors && personArray.length === 2 && isReportPreviewAction) {
254-
return (
255-
<View style={[styles.flexRow]}>
256-
<ReportActionItemFragment
257-
style={[styles.flex1]}
258-
key={`person-${action?.reportActionID}-${0}`}
259-
accountID={actorAccountID ?? -1}
260-
fragment={{...personArray.at(0), type: 'TEXT', text: displayName ?? ''}}
261-
delegateAccountID={action?.delegateAccountID}
262-
isSingleLine
263-
actorIcon={icon}
264-
moderationDecision={getReportActionMessage(action)?.moderationDecision?.decision}
265-
/>
266-
<Text
267-
numberOfLines={1}
268-
style={[styles.chatItemMessageHeaderSender, styles.pre]}
269-
>
270-
{` & `}
271-
</Text>
272-
<ReportActionItemFragment
273-
style={[styles.flex1]}
274-
key={`person-${action?.reportActionID}-${1}`}
275-
accountID={parseInt(`${secondaryAvatar?.id ?? -1}`, 10)}
276-
fragment={{...personArray.at(1), type: 'TEXT', text: secondaryAvatar.name ?? ''}}
277-
delegateAccountID={action?.delegateAccountID}
278-
isSingleLine
279-
actorIcon={secondaryAvatar}
280-
moderationDecision={getReportActionMessage(action)?.moderationDecision?.decision}
281-
/>
282-
</View>
283-
);
284-
}
285-
return (
286-
<View>
287-
{personArray.map((fragment, index) => (
288-
<ReportActionItemFragment
289-
style={[styles.flex1]}
290-
// eslint-disable-next-line react/no-array-index-key
291-
key={`person-${action?.reportActionID}-${index}`}
292-
accountID={actorAccountID ?? -1}
293-
fragment={{...fragment, type: fragment?.type ?? '', text: fragment?.text ?? ''}}
294-
delegateAccountID={action?.delegateAccountID}
295-
isSingleLine
296-
actorIcon={icon}
297-
moderationDecision={getReportActionMessage(action)?.moderationDecision?.decision}
298-
/>
299-
))}
300-
</View>
301-
);
302-
};
303-
}, [
304-
displayAllActors,
305-
secondaryAvatar,
306-
isReportPreviewAction,
307-
personArray,
308-
styles.flexRow,
309-
styles.flex1,
310-
styles.chatItemMessageHeaderSender,
311-
styles.pre,
312-
action,
313-
actorAccountID,
314-
displayName,
315-
icon,
316-
]);
317-
318234
const hasEmojiStatus = !displayAllActors && status?.emojiCode;
319235
const formattedDate = DateUtils.getStatusUntilDate(status?.clearAfter ?? '');
320236
const statusText = status?.text ?? '';
@@ -345,7 +261,18 @@ function ReportActionItemSingle({
345261
accessibilityLabel={actorHint}
346262
role={CONST.ROLE.BUTTON}
347263
>
348-
{getHeading()}
264+
{personArray?.map((fragment, index) => (
265+
<ReportActionItemFragment
266+
// eslint-disable-next-line react/no-array-index-key
267+
key={`person-${action?.reportActionID}-${index}`}
268+
accountID={actorAccountID ?? -1}
269+
fragment={{...fragment, type: fragment.type ?? '', text: fragment.text ?? ''}}
270+
delegateAccountID={action?.delegateAccountID}
271+
isSingleLine
272+
actorIcon={icon}
273+
moderationDecision={getReportActionMessage(action)?.moderationDecision?.decision}
274+
/>
275+
))}
349276
</PressableWithoutFeedback>
350277
{!!hasEmojiStatus && (
351278
<Tooltip text={statusTooltipText}>

0 commit comments

Comments
 (0)