Skip to content

[$250] Refactor Search highlight logic from timer-based to readiness-based #85521

@JakubKorytko

Description

@JakubKorytko

On the native platforms (specifically observed on Android), scrolling to and highlighting a newly added expense is inconsistent. This race condition exists on main but has become more apparent following recent performance-focused changes.

Current Behavior

The search highlight flow is currently timer-based.

  1. After submitting an expense outside of the Inbox, the new transaction is marked for highlight on the Search route.
  2. This highlight state is cleared after a fixed timeout.
  3. The actual scroll/highlight action triggers only after the Search list has mounted, data is grouped/sorted, and the list layout callback runs.

Problem

If Search rendering is delayed - due to navigation timing, loading skeletons, or heavy list processing - the highlight state often expires before the row is reachable. This results in the expense neither being scrolled into view nor highlighted.

Proposed solution

We need to move away from a timeout-based lifecycle and implement a readiness-based approach.

  • Persist state: Maintain the manual highlight state/flag until the target transaction is confirmed to be present in the rendered Search data.
  • Trigger on readiness: Only execute the scroll and highlight once the list is layout-ready and the specific item exists in the DOM/list index.
  • Explicit cleanup: Clear the highlight flag only after the scroll/highlight animation has successfully initiated.

Impact

  • Consistency: Ensures the "Add Expense" flow always provides visual confirmation of the new entry, regardless of device performance or network latency.
  • UX: Eliminates the "vanishing highlight" bug where the UI state resets before the user even sees the Search page.

Note

This was identified during a performance PR where the timing window became easier to hit, but the root cause is an architectural race condition in the Search highlight logic.

Observed here: #84910 (comment)

Issue OwnerCurrent Issue Owner: @borys3kk
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022034273899120343057
  • Upwork Job ID: 2034273899120343057
  • Last Price Increase: 2026-03-18

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
No fields configured for issues without a type.

Projects

Status

LOW

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions