From 1d554eef5c9067fdcddc06d44d336e31467ed707 Mon Sep 17 00:00:00 2001 From: Hubert Sosinski Date: Tue, 3 Mar 2026 09:56:23 +0100 Subject: [PATCH 1/4] skip requiresAttentionFromCurrentUser recomputation when pre-computed value is available --- src/libs/ReportUtils.ts | 5 ++++- src/libs/SidebarUtils.ts | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index ed513b787bd01..7564849a00bae 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -9312,6 +9312,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({ @@ -9327,6 +9329,7 @@ function reasonForReportToBeInOptionList({ login, includeDomainEmail = false, isReportArchived, + requiresAttention, }: ShouldReportBeInOptionListParams): ValueOf | null { const isInDefaultMode = !isInFocusMode; @@ -9407,7 +9410,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 781381ecf1f30..65e3def962a21 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -273,6 +273,7 @@ function shouldDisplayReportInLHN( draftComment, includeSelfDM: true, isReportArchived, + requiresAttention: reportAttributes?.[report?.reportID]?.requiresAttention, }); return {shouldDisplay}; From a098f5f15ff71ec50ea927bf1129e2486ed915ca Mon Sep 17 00:00:00 2001 From: Hubert Sosinski Date: Tue, 3 Mar 2026 10:05:53 +0100 Subject: [PATCH 2/4] extract requiresAttention to variable to avoid double lookup --- src/libs/SidebarUtils.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 65e3def962a21..35ae1da739778 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -246,6 +246,7 @@ function shouldDisplayReportInLHN( } // Check if report should override hidden status + const requiresAttention = reportAttributes?.[report?.reportID]?.requiresAttention; const isSystemChat = isSystemChatUtil(report); const shouldOverrideHidden = !!draftComment || @@ -254,7 +255,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) { @@ -273,7 +274,7 @@ function shouldDisplayReportInLHN( draftComment, includeSelfDM: true, isReportArchived, - requiresAttention: reportAttributes?.[report?.reportID]?.requiresAttention, + requiresAttention, }); return {shouldDisplay}; From dc41d99b6be124c110ee81b9fe07ec19e4c794ca Mon Sep 17 00:00:00 2001 From: Hubert Sosinski Date: Mon, 9 Mar 2026 09:47:10 +0100 Subject: [PATCH 3/4] make reportAttributes required parameter --- src/libs/ReportUtils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index bb03445c1e9e6..c35bfc67a2704 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -9330,9 +9330,9 @@ function hasReportErrorsOtherThanFailedReceipt( doesReportHaveViolations: boolean, transactionViolations: OnyxCollection, transactions: OnyxCollection, - reportAttributes?: ReportAttributesDerivedValue['reports'], + reportAttributes: ReportAttributesDerivedValue['reports'], ) { - const allReportErrors = reportAttributes?.[report?.reportID]?.reportErrors ?? {}; + const allReportErrors = reportAttributes[report?.reportID]?.reportErrors ?? {}; const transactionReportActions = getAllReportActions(report.reportID); const oneTransactionThreadReportID = getOneTransactionThreadReportID(report, chatReport, transactionReportActions, undefined); let doesTransactionThreadReportHasViolations = false; From c23f7ac046795be1c7dcb03de55cce9f609d49eb Mon Sep 17 00:00:00 2001 From: Hubert Sosinski Date: Tue, 10 Mar 2026 13:55:54 +0100 Subject: [PATCH 4/4] prettier fix --- src/libs/ReportUtils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 1056c5d2fdfe0..0e8657bc00b24 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -9375,9 +9375,9 @@ function hasReportErrorsOtherThanFailedReceipt( doesReportHaveViolations: boolean, transactionViolations: OnyxCollection, transactions: OnyxCollection, - reportAttributes: ReportAttributesDerivedValue['reports'], + reportAttributes?: ReportAttributesDerivedValue['reports'], ) { - const allReportErrors = reportAttributes[report?.reportID]?.reportErrors ?? {}; + const allReportErrors = reportAttributes?.[report?.reportID]?.reportErrors ?? {}; const transactionReportActions = getAllReportActions(report.reportID); const oneTransactionThreadReportID = getOneTransactionThreadReportID(report, chatReport, transactionReportActions, undefined); let doesTransactionThreadReportHasViolations = false;