Skip to content

[$250] Performance: optimize LHN sidebar sorting with pre-computed sort keys #87939

Description

@mountiny

Problem

Left-hand navigation (LHN) sidebar sorting used Intl.Collator.compare() on every comparison in each sort pass — on the order of hundreds of thousands of calls per sort on large accounts. Each call applies locale-sensitive collation rules and is relatively expensive.

Approach (PR)

Pre-compute sort keys per report name: lowercase, zero-pad numeric segments, cache at module scope. Sort primarily compares plain strings; fall back to Intl.Collator only when sort keys tie (a small fraction of comparisons).

Tradeoff: Locale-specific ordering for some diacritics (e.g. Swedish ä/ö, German ß, Spanish ñ) follows Unicode codepoint order instead of full locale collation. Numeric sorting is preserved.

Reported impact (author): iOS ~740ms → ~164ms; Android ~2.1s → ~380ms on tested accounts.

Implementation

#87847 — Optimize LHN sidebar sorting with pre-computed sort keys

Related (from PR)

QA / verification

  • Fresh/small account: create chats, pin one (stays on top), type in another (ordering updates as before).
  • High–chat-count account: sidebar still sorts sensibly; spot-check names with diacritics if relevant to your locale.
  • No new JS console errors.
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022044208373635887976
  • Upwork Job ID: 2044208373635887976
  • Last Price Increase: 2026-04-15
Issue OwnerCurrent Issue Owner: @mallenexpensify

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions