From 4ba67b37f36a3fff2890784bfe6b007689ffac07 Mon Sep 17 00:00:00 2001 From: Georgia Monahan Date: Mon, 14 Oct 2024 12:47:28 +0900 Subject: [PATCH 1/6] Revert "Merge pull request #50557 from Expensify/revert-50341-georgia-heading" This reverts commit b70ad57859d65351c14b74ed48ca137cf9254b09, reversing changes made to ab5175c3d48061cd8fb422bab448a4a61caf018b. --- .../home/report/ReportActionItemSingle.tsx | 125 ++++++++++++++---- 1 file changed, 99 insertions(+), 26 deletions(-) diff --git a/src/pages/home/report/ReportActionItemSingle.tsx b/src/pages/home/report/ReportActionItemSingle.tsx index 88955766c991..0ed4ae665781 100644 --- a/src/pages/home/report/ReportActionItemSingle.tsx +++ b/src/pages/home/report/ReportActionItemSingle.tsx @@ -150,24 +150,40 @@ function ReportActionItemSingle({ } else { secondaryAvatar = {name: '', source: '', type: 'avatar'}; } - const icon = { - source: avatarSource ?? FallbackAvatar, - type: isWorkspaceActor ? CONST.ICON_TYPE_WORKSPACE : CONST.ICON_TYPE_AVATAR, - name: primaryDisplayName ?? '', - id: avatarId, - }; + const icon = useMemo( + () => ({ + source: avatarSource ?? FallbackAvatar, + type: isWorkspaceActor ? CONST.ICON_TYPE_WORKSPACE : CONST.ICON_TYPE_AVATAR, + name: primaryDisplayName ?? '', + id: avatarId, + }), + [avatarSource, isWorkspaceActor, primaryDisplayName, 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 = displayName - ? [ - { - type: 'TEXT', - text: displayName, - }, - ] - : action?.person; + 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 reportID = report?.reportID; const iouReportID = iouReport?.reportID; @@ -231,6 +247,74 @@ function ReportActionItemSingle({ ); }; + + const getHeading = useCallback(() => { + return () => { + if (displayAllActors && personArray.length === 2 && isReportPreviewAction) { + return ( + + + + {` & `} + + + + ); + } + return ( + + {personArray.map((fragment, index) => ( + + ))} + + ); + }; + }, [ + 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 ?? ''; @@ -261,18 +345,7 @@ function ReportActionItemSingle({ accessibilityLabel={actorHint} role={CONST.ROLE.BUTTON} > - {personArray?.map((fragment, index) => ( - - ))} + {getHeading()} {!!hasEmojiStatus && ( From b5446014aba60da0c10ac7ee1e4354060005bce9 Mon Sep 17 00:00:00 2001 From: Georgia Monahan Date: Mon, 14 Oct 2024 14:09:54 +0900 Subject: [PATCH 2/6] Fix text for long names --- src/pages/home/report/ReportActionItemSingle.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pages/home/report/ReportActionItemSingle.tsx b/src/pages/home/report/ReportActionItemSingle.tsx index 0ed4ae665781..43a601a4dccb 100644 --- a/src/pages/home/report/ReportActionItemSingle.tsx +++ b/src/pages/home/report/ReportActionItemSingle.tsx @@ -171,7 +171,7 @@ function ReportActionItemSingle({ text: displayName, }, ] - : [action?.person?.at(0)] ?? []; + : [action?.person?.at(0)].filter(Boolean) ?? []; if (displayAllActors && secondaryAvatar?.name) { return [ @@ -254,7 +254,7 @@ function ReportActionItemSingle({ return ( {` & `} Date: Mon, 14 Oct 2024 14:37:27 +0900 Subject: [PATCH 3/6] lint --- src/pages/home/report/ReportActionItemSingle.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pages/home/report/ReportActionItemSingle.tsx b/src/pages/home/report/ReportActionItemSingle.tsx index 43a601a4dccb..a977c62dd6b5 100644 --- a/src/pages/home/report/ReportActionItemSingle.tsx +++ b/src/pages/home/report/ReportActionItemSingle.tsx @@ -306,6 +306,8 @@ function ReportActionItemSingle({ isReportPreviewAction, personArray, styles.flexRow, + styles.flexShrink0, + styles.flexShrink1, styles.flex1, styles.chatItemMessageHeaderSender, styles.pre, From 7b387846f9d937eecbb45507baa398f0259b4265 Mon Sep 17 00:00:00 2001 From: Georgia Monahan Date: Tue, 15 Oct 2024 12:54:17 +0900 Subject: [PATCH 4/6] use managerIcon --- src/libs/ReportUtils.ts | 2 +- src/pages/home/report/ReportActionItemSingle.tsx | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 2623fab86a05..04d62fbfe64e 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -2371,7 +2371,7 @@ function getIcons( // For one transaction IOUs, display a simplified report icon if (isOneTransactionReport(report?.reportID ?? '-1')) { - return [ownerIcon]; + return [managerIcon]; } return isManager ? [managerIcon, ownerIcon] : [ownerIcon, managerIcon]; diff --git a/src/pages/home/report/ReportActionItemSingle.tsx b/src/pages/home/report/ReportActionItemSingle.tsx index a977c62dd6b5..d784ad859365 100644 --- a/src/pages/home/report/ReportActionItemSingle.tsx +++ b/src/pages/home/report/ReportActionItemSingle.tsx @@ -95,7 +95,8 @@ function ReportActionItemSingle({ let actorHint = (login || (displayName ?? '')).replace(CONST.REGEX.MERGED_ACCOUNT_PREFIX, ''); const isTripRoom = ReportUtils.isTripRoom(report); const isReportPreviewAction = action?.actionName === CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW; - const displayAllActors = isReportPreviewAction && !isTripRoom; + const icons = ReportUtils.getIcons(iouReport ?? null, personalDetails); + const displayAllActors = isReportPreviewAction && !isTripRoom && (icons ? icons.length > 1 : true); const isInvoiceReport = ReportUtils.isInvoiceReport(iouReport ?? null); const isWorkspaceActor = isInvoiceReport || (ReportUtils.isPolicyExpenseChat(report) && (!actorAccountID || displayAllActors)); const ownerAccountID = iouReport?.ownerAccountID ?? action?.childOwnerAccountID; From 4e1a806db599e17e9ed3b6f65351b54937bfcbc1 Mon Sep 17 00:00:00 2001 From: Georgia Monahan Date: Tue, 12 Nov 2024 12:59:48 +0000 Subject: [PATCH 5/6] code review --- src/libs/ReportUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 4deb08f8b8f2..0edf64e603c3 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -1682,7 +1682,7 @@ function hasOnlyNonReimbursableTransactions(iouReportID: string | undefined): bo */ function isOneTransactionReport(reportID: string): boolean { const reportActions = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`] ?? ([] as ReportAction[]); - return ReportActionsUtils.getOneTransactionThreadReportID(reportID, reportActions) !== null; + return !!ReportActionsUtils.getOneTransactionThreadReportID(reportID, reportActions); } /* From e1ab6d61b91999f123a5ab14db8dda92909573ad Mon Sep 17 00:00:00 2001 From: Georgia Monahan Date: Thu, 14 Nov 2024 18:13:53 +0000 Subject: [PATCH 6/6] IOS --- src/pages/home/report/ReportActionItemSingle.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/home/report/ReportActionItemSingle.tsx b/src/pages/home/report/ReportActionItemSingle.tsx index 28f10d525410..d23c027184e9 100644 --- a/src/pages/home/report/ReportActionItemSingle.tsx +++ b/src/pages/home/report/ReportActionItemSingle.tsx @@ -267,6 +267,7 @@ function ReportActionItemSingle({ /> {` & `}