Coming from here
Background:
When a report is opened via search, it triggers a navigation state change. This causes useCurrentReportID to update the currentReportID, which flows into useSidebarOrderedReports and leads to a recalculation of reportsToDisplayInLHN.
Problem:
When the sidebar recalculates due to navigation or data updates, even when the current report hasn't changed or the report data is the same, it causes redundant sortReportsToDisplayInLHN calls, which degrades performance in larger accounts.
Solution:
Implement a series of improvements to reduce unnecessary sortReportsToDisplayInLHN calls and improve performance:
- Add change detection to updateCurrentReportID to exit early when the report ID hasn't changed.
- Add useDeepCompareRef to avoid triggering re-sorting unless report data meaningfully changes.
- Replace inefficient forEach loops with for...of in performance-sensitive iteration.
- Break down complex update logic into smaller, purpose-specific functions for clarity and efficiency.
The above changes improve the performance of sortReportsToDisplayInLHN by 40–55%:
- Before: 12–15 ms (small accounts), ~60 ms (large accounts), function appears 9–12 times in the trace
- After: 6 ms (small accounts), 30–40 ms (large accounts), function appears 4–6 times in the trace
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~021952688466440387545
- Upwork Job ID: 1952688466440387545
- Last Price Increase: 2025-08-05
Issue Owner
Current Issue Owner: @hoangzinh
Issue Owner
Current Issue Owner: @OlimpiaZurek
Coming from here
Background:
When a report is opened via search, it triggers a navigation state change. This causes useCurrentReportID to update the currentReportID, which flows into useSidebarOrderedReports and leads to a recalculation of reportsToDisplayInLHN.
Problem:
When the sidebar recalculates due to navigation or data updates, even when the current report hasn't changed or the report data is the same, it causes redundant sortReportsToDisplayInLHN calls, which degrades performance in larger accounts.
Solution:
Implement a series of improvements to reduce unnecessary sortReportsToDisplayInLHN calls and improve performance:
The above changes improve the performance of sortReportsToDisplayInLHN by 40–55%:
Upwork Automation - Do Not Edit
Issue Owner
Current Issue Owner: @hoangzinhIssue Owner
Current Issue Owner: @OlimpiaZurek