From c7acd8c3249ced2da5cd0af95171a70606e2ecee Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Tue, 7 May 2024 14:38:44 -1000 Subject: [PATCH] Revert 41187 --- src/libs/OptionsListUtils.ts | 12 +++++++++--- src/libs/SidebarUtils.ts | 8 +++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 12209cfcb361..082952e58f9e 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -284,8 +284,14 @@ Onyx.connect({ // The report is only visible if it is the last action not deleted that // does not match a closed or created state. - const reportActionsForDisplay = sortedReportActions.filter((reportAction) => ReportActionUtils.shouldReportActionBeVisibleAsLastAction(reportAction)); - visibleReportActionItems[reportID] = reportActionsForDisplay[0]; + const reportActionsForDisplay = sortedReportActions.filter( + (reportAction, actionKey) => + ReportActionUtils.shouldReportActionBeVisible(reportAction, actionKey) && + !ReportActionUtils.isWhisperAction(reportAction) && + reportAction.actionName !== CONST.REPORT.ACTIONS.TYPE.CREATED && + reportAction.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE, + ); + visibleReportActionItems[reportID] = reportActionsForDisplay[reportActionsForDisplay.length - 1]; }, }); @@ -562,7 +568,7 @@ function getAlternateText(option: ReportUtils.OptionData, {showChatPreviewLine = * Get the last message text from the report directly or from other sources for special cases. */ function getLastMessageTextForReport(report: OnyxEntry, lastActorDetails: Partial | null, policy?: OnyxEntry): string { - const lastReportAction = visibleReportActionItems[report?.reportID ?? ''] ?? null; + const lastReportAction = allSortedReportActions[report?.reportID ?? '']?.find((reportAction) => ReportActionUtils.shouldReportActionBeVisibleAsLastAction(reportAction)) ?? null; // some types of actions are filtered out for lastReportAction, in some cases we need to check the actual last action const lastOriginalReportAction = lastReportActions[report?.reportID ?? ''] ?? null; diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 74fab75dcc18..c0d0c9020a64 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -36,7 +36,13 @@ Onyx.connect({ // The report is only visible if it is the last action not deleted that // does not match a closed or created state. - const reportActionsForDisplay = actionsArray.filter((reportAction) => ReportActionsUtils.shouldReportActionBeVisibleAsLastAction(reportAction)); + const reportActionsForDisplay = actionsArray.filter( + (reportAction, actionKey) => + ReportActionsUtils.shouldReportActionBeVisible(reportAction, actionKey) && + !ReportActionsUtils.isWhisperAction(reportAction) && + reportAction.actionName !== CONST.REPORT.ACTIONS.TYPE.CREATED && + reportAction.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE, + ); visibleReportActionItems[reportID] = reportActionsForDisplay[reportActionsForDisplay.length - 1]; },