Skip to content

Commit 4ba67b3

Browse files
committed
Revert "Merge pull request #50557 from Expensify/revert-50341-georgia-heading"
This reverts commit b70ad57, reversing changes made to ab5175c.
1 parent df19b26 commit 4ba67b3

File tree

1 file changed

+99
-26
lines changed

1 file changed

+99
-26
lines changed

src/pages/home/report/ReportActionItemSingle.tsx

+99-26
Original file line numberDiff line numberDiff line change
@@ -150,24 +150,40 @@ function ReportActionItemSingle({
150150
} else {
151151
secondaryAvatar = {name: '', source: '', type: 'avatar'};
152152
}
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-
};
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+
);
159162

160163
// Since the display name for a report action message is delivered with the report history as an array of fragments
161164
// we'll need to take the displayName from personal details and have it be in the same format for now. Eventually,
162165
// we should stop referring to the report history items entirely for this information.
163-
const personArray = displayName
164-
? [
165-
{
166-
type: 'TEXT',
167-
text: displayName,
168-
},
169-
]
170-
: action?.person;
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]);
171187

172188
const reportID = report?.reportID;
173189
const iouReportID = iouReport?.reportID;
@@ -231,6 +247,74 @@ function ReportActionItemSingle({
231247
</UserDetailsTooltip>
232248
);
233249
};
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+
234318
const hasEmojiStatus = !displayAllActors && status?.emojiCode;
235319
const formattedDate = DateUtils.getStatusUntilDate(status?.clearAfter ?? '');
236320
const statusText = status?.text ?? '';
@@ -261,18 +345,7 @@ function ReportActionItemSingle({
261345
accessibilityLabel={actorHint}
262346
role={CONST.ROLE.BUTTON}
263347
>
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-
))}
348+
{getHeading()}
276349
</PressableWithoutFeedback>
277350
{!!hasEmojiStatus && (
278351
<Tooltip text={statusTooltipText}>

0 commit comments

Comments
 (0)