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 Owner
Current Issue Owner: @mallenexpensify
Problem
The
TODOSderived 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
TODOSderived value and move computation into the React lifecycle via theuseTodoCountshook with an optionalenabledparameter. Whenenabledis false, the hook freezes and returns the last captured result using a React-Compiler-safe freeze pattern.SearchTypeMenuNarrowandForYouSectionnow passuseIsFocused()so to-do counts stop recomputing on background Onyx writes while unfocused, and recompute once on refocus.PR
#94677
Issue Owner
Current Issue Owner: @mallenexpensify