diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 21f2fd9bccc7e..0e8657bc00b24 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -9407,6 +9407,8 @@ type ShouldReportBeInOptionListParams = { includeDomainEmail?: boolean; isReportArchived: boolean | undefined; draftComment: string | undefined; + /** Pre-computed value from reportAttributes derived value. When provided, skips the expensive requiresAttentionFromCurrentUser recomputation. */ + requiresAttention?: boolean; }; function reasonForReportToBeInOptionList({ @@ -9422,6 +9424,7 @@ function reasonForReportToBeInOptionList({ login, includeDomainEmail = false, isReportArchived, + requiresAttention, }: ShouldReportBeInOptionListParams): ValueOf | null { const isInDefaultMode = !isInFocusMode; @@ -9502,7 +9505,7 @@ function reasonForReportToBeInOptionList({ return CONST.REPORT_IN_LHN_REASONS.HAS_DRAFT_COMMENT; } - if (requiresAttentionFromCurrentUser(report, undefined, isReportArchived)) { + if (requiresAttention ?? requiresAttentionFromCurrentUser(report, undefined, isReportArchived)) { return CONST.REPORT_IN_LHN_REASONS.HAS_GBR; } diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 7ba03985c93fe..1f3c622c35406 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -249,6 +249,7 @@ function shouldDisplayReportInLHN( } // Check if report should override hidden status + const requiresAttention = reportAttributes?.[report?.reportID]?.requiresAttention; const isSystemChat = isSystemChatUtil(report); const shouldOverrideHidden = !!draftComment || @@ -257,7 +258,7 @@ function shouldDisplayReportInLHN( isSystemChat || !!report.isPinned || // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - reportAttributes?.[report?.reportID]?.requiresAttention || + requiresAttention || (report.isOwnPolicyExpenseChat && !isReportArchived); if (isHidden && !shouldOverrideHidden) { @@ -276,6 +277,7 @@ function shouldDisplayReportInLHN( draftComment, includeSelfDM: true, isReportArchived, + requiresAttention, }); return {shouldDisplay};