Skip to content

[Due for payment 2025-06-12] [$250] Optimize useLoadReportActions performance for large sets #63026

@gedu

Description

@gedu

Proposal

Optimize reportActions loading performance for large sets

Problem

When users have chat histories with 1,000+ report actions, the useLoadReportActions hook takes over 3000ms to process the data, which causes chat interfaces to freeze and prevents users from efficiently navigating their conversations.

Solution

Optimize useLoadReportActions hook in the following way to reduce its’ processing time:
Replace the current O(n²) Array.map + Array.includes pattern with O(1) Set-based lookups by converting allReportActionIDs into a Set for instant membership testing.
Eliminate redundant iterations by processing all report actions in a single pass, tracking first and last occurrences for both current report and transaction thread simultaneously.

Thread: https://expensify.slack.com/archives/C05LX9D6E07/p1748012519024809

Improvements:
CMD+K showing modal with a 4x CPU throttling.
Before: 4sec
After: 1sec

Image
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021928073157688472631
  • Upwork Job ID: 1928073157688472631
  • Last Price Increase: 2025-05-29
Issue OwnerCurrent Issue Owner: @gedu

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 contributor

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions