Skip to content

[Due for payment 2026-08-08] perf: skip full transactions scan in computeReportName #97347

Description

@mountiny

Problem

computeReportName scanned the entire transactions collection (Object.values(transactions).filter(...)) on every single report-name computation, purely to pass the result into isClosedExpenseReportWithNoExpenses. That callee early-returns for anything that isn't a closed expense report without ever touching the transactions array, so the full-collection scan was wasted work in almost every case. On accounts with many transactions this made each report-name compute O(all transactions) — O(reports × transactions) for a full reportAttributes sweep, such as the one during OpenApp, which froze the app for ~20s on a large customer account.

Solution

Gate the scan behind the cheap checks first (report.statusNum === CLOSED && isExpenseReport(report)), and when it does need to run, filter the transactions down to just that report's own transactions rather than the whole collection. Behavior is identical — only the work required to reach the same result changes. On the large customer account the post-OpenApp freeze is gone and the heavy computation drops from 20s to 300ms.

PR

#97340

Issue OwnerCurrent Issue Owner: @ZhenjaHorbach

Metadata

Metadata

Labels

Type

No type

Projects

Status
CRITICAL

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions