Skip to content

[Due for payment 2026-03-04] [$250] Eliminate redundant sorting in LHN renderItem #83025

@mountiny

Description

@mountiny

Coming from proposal here

Background:

The LHN renders a scrollable list of all user-visible reports via a FlashList renderItem callback. For each report row, renderItem derives several values from that report's actions: the last visible action, the last displayable action, the one-transaction thread report ID, and the last IOU money request action. Report actions are stored as unsorted objects in Onyx. A collection-level Onyx callback on ONYXKEYS.COLLECTION.REPORT_ACTIONS already fires on every data change and iterates over all report-action collections to maintain pre-computed caches (allSortedReportActions, lastReportActions, lastVisibleReportActions). Additionally, the reportAttributes OnyxDerived config already computes per-report metadata reactively whenever its Onyx dependencies change.

Problem:

When the LHN re-renders on a heavy account, each renderItem call independently performs two sort operations, a filter pass, and a find scan over that report's actions, which slows down initial navigation to the inbox and degrades scroll frame rates as the number of reports grows

Solution:

  1. Expose oneTransactionThreadReportID through the existing reportAttributes OnyxDerived config which already computes it but was discarding it so renderItem reads it reactively instead of calling getOneTransactionThreadReportID() per item.
  2. Merge the .filter() and .find() passes in the REPORT_ACTIONS collection callback into a single for loop with early break, caching results in lastVisibleReportActions and lastVisibleIOUMoneyActions.
  3. Replace the two per-item sort calls with a single-pass findLastReportActions() using an isNewerReportAction comparator, reducing per-item complexity

Draft PR
Performance gain:
ManualNavigateToInboxTab span reduced ~30ms

Issue OwnerCurrent Issue Owner: @bfitzexpensify
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022024766686700575645
  • Upwork Job ID: 2024766686700575645
  • Last Price Increase: 2026-03-02

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributorHelp WantedApply this label when an issue is open to proposals by contributorsOverdue

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions