Skip to content

[Due for payment 2026-07-08] refactor: remove todos derived value #94686

Description

@mountiny

Problem

The TODOS derived value runs outside the React lifecycle and recomputes on any dependency change (reports, transactions, report actions, policies, etc.) regardless of whether anything currently needs the result. That means the expensive to-do classification (createTodosReportsAndTransactions) runs constantly in the background — even when no screen is displaying the counts.

Solution

Remove the TODOS derived value and move computation into the React lifecycle via the useTodoCounts hook with an optional enabled parameter. When enabled is false, the hook freezes and returns the last captured result using a React-Compiler-safe freeze pattern. SearchTypeMenuNarrow and ForYouSection now pass useIsFocused() so to-do counts stop recomputing on background Onyx writes while unfocused, and recompute once on refocus.

PR

#94677

Issue OwnerCurrent Issue Owner: @mallenexpensify

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionDailyKSv2Task

Type

No type

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions