Skip to content

[Due for payment 2026-06-30] [No QA] Avoid building archived-reports Set in findLastAccessedReport path #94166

Description

@mountiny

Problem

findLastAccessedReport previously required callers to pass a pre-built ArchivedReportsIDSet — a Set covering all archived report IDs. Every caller had to build that set by iterating the full reportNameValuePairs collection first, which is expensive at scale (~100k entries on high-traffic accounts) and added roughly 14s to app startup and report opening.

Solution

Changed the 4th parameter of findLastAccessedReport to accept the raw OnyxCollection<ReportNameValuePairs> instead of a pre-built Set. Archived status is now checked via a direct O(1) per-report key lookup (isArchivedReport(reportNameValuePairsCollection?.[key])) during filtering, eliminating upfront Set construction. All callers were updated to pass the collection they already subscribe to via useOnyx(ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS). A module-scoped Onyx.connect fallback is kept for the rare cases where no collection is passed.

PR

#94146

Issue OwnerCurrent Issue Owner: @mallenexpensify

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionDailyKSv2Task

Type

No type

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions