Skip to content

[Due for payment 2026-04-23] [$250] Performance: avoid double scan of reports in useParticipantsInvoiceReport #87685

@mountiny

Description

@mountiny

Problem

useParticipantsInvoiceReport uses a custom Onyx selector (allInvoiceReportsSelector) that walks the entire COLLECTION.REPORT map (via mapOnyxCollectionItems) on every reports update to build a filtered "invoice rooms only" collection. That result is then compared (e.g. with deep equality) before a useMemo runs a second pass (Object.values(...).find(...)) to locate the matching invoice report for the receiver/policy.

So each reports change pays for:

  1. A full-collection iteration + intermediate structure in the selector path
  2. Another iteration in useMemo for matching

This hook is used on money-request / invoice-related flows (e.g. confirmation step, pay actions, report header), so the extra work shows up when opening those surfaces, especially on accounts with large report collections.

Expected outcome

  • Subscribe to the full reports collection (or equivalent) without a redundant pre-filter selector that scans the whole map on every update.
  • Perform invoice-room checks and receiver/policy matching in one pass inside useMemo (same behavior, fewer iterations and less allocation).

Implementation

Addressed in: #87580

QA / verification

  • No change in which invoice report is resolved for a given receiver + policy.
  • No new JS console errors on flows that call this hook (money request / pay invoice paths).
  • Optional: profile before/after on a high–report-count account when opening money request.

Related

  • PR: #87580 — Remove redundant selector loop in useParticipantsInvoiceReport
Issue OwnerCurrent Issue Owner: @hungvu193
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022042756144459250432
  • Upwork Job ID: 2042756144459250432
  • Last Price Increase: 2026-04-11

Metadata

Metadata

Labels

BugSomething 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 contributors

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