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 Owner
Current Issue Owner: @ZhenjaHorbach
Problem
computeReportNamescanned the entire transactions collection (Object.values(transactions).filter(...)) on every single report-name computation, purely to pass the result intoisClosedExpenseReportWithNoExpenses. 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 fullreportAttributessweep, such as the one duringOpenApp, 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-OpenAppfreeze is gone and the heavy computation drops from 20s to 300ms.PR
#97340
Issue Owner
Current Issue Owner: @ZhenjaHorbach