From fe60ae0395c101fce154c2e9b98b033bc7f3c43d Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Mon, 29 Apr 2024 10:53:47 +0800 Subject: [PATCH] fix report preview while scanning is filtered out from the last action --- src/libs/OptionsListUtils.ts | 12 +++--------- src/libs/SidebarUtils.ts | 8 +------- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 8166036e8e17..cea3bb3b958c 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -262,14 +262,8 @@ 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, 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]; + const reportActionsForDisplay = sortedReportActions.filter((reportAction) => ReportActionUtils.shouldReportActionBeVisibleAsLastAction(reportAction)); + visibleReportActionItems[reportID] = reportActionsForDisplay[0]; }, }); @@ -549,7 +543,7 @@ function getAlternateText( * 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 = allSortedReportActions[report?.reportID ?? '']?.find((reportAction) => ReportActionUtils.shouldReportActionBeVisibleAsLastAction(reportAction)) ?? null; + const lastReportAction = visibleReportActionItems[report?.reportID ?? ''] ?? 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; let lastMessageTextFromReport = ''; diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 4f1a35ee1d87..0bbc2e484a46 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -35,13 +35,7 @@ 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, actionKey) => - ReportActionsUtils.shouldReportActionBeVisible(reportAction, actionKey) && - !ReportActionsUtils.isWhisperAction(reportAction) && - reportAction.actionName !== CONST.REPORT.ACTIONS.TYPE.CREATED && - reportAction.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE, - ); + const reportActionsForDisplay = actionsArray.filter((reportAction) => ReportActionsUtils.shouldReportActionBeVisibleAsLastAction(reportAction)); visibleReportActionItems[reportID] = reportActionsForDisplay[reportActionsForDisplay.length - 1]; },