Skip to content

[Due for payment 2025-09-02] [Due for payment 2025-08-26] [$250] Prevent redundant Sidebar sorting #67894

@mountiny

Description

@mountiny

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 OwnerCurrent Issue Owner: @hoangzinh
Issue OwnerCurrent Issue Owner: @OlimpiaZurek

Metadata

Metadata

Labels

AutoAssignerNewDotQualityUsed to assign quality issues to engineersAwaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.ExternalAdded to denote the issue can be worked on by a contributorWeeklyKSv2

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions