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:
- A full-collection iteration + intermediate structure in the selector path
- 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 Owner
Current 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
Problem
useParticipantsInvoiceReportuses a custom Onyxselector(allInvoiceReportsSelector) that walks the entireCOLLECTION.REPORTmap (viamapOnyxCollectionItems) on every reports update to build a filtered "invoice rooms only" collection. That result is then compared (e.g. with deep equality) before auseMemoruns a second pass (Object.values(...).find(...)) to locate the matching invoice report for the receiver/policy.So each reports change pays for:
useMemofor matchingThis 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
useMemo(same behavior, fewer iterations and less allocation).Implementation
Addressed in: #87580
QA / verification
Related
useParticipantsInvoiceReportIssue Owner
Current Issue Owner: @hungvu193Upwork Automation - Do Not Edit