Skip to content

[Due for payment 2026-09-01] Home "Recently added" widget shows "No recent expenses" when the Search request fails or is still in flight #98895

Closed

Description

@melvin-bot

Problem

On the Home page, the "Recently added" section can incorrectly show "No recent expenses" even when the user has plenty of expenses locally. Two distinct triggers were found while diagnosing a report from @JmillsExpensify:

  1. Failed in-flight Search wipes the section and it never recovers. If the Search request backing that section fails while in flight, the failure handling clears the stored results and leaves an error marker in their place. The section only refetches when Home regains focus or when the query changes — so if the user is already sitting on Home, it stays empty indefinitely (observed for 30+ minutes). Because the section only has two visible states (rows or the empty message), the error reads as "No recent expenses" rather than as a failure.

  2. No loading state during a slow Search makes Home claim you have no expenses. The query has no date bound, so the server sorts every accessible transaction before cutting to ~51 results, which can take 5+ seconds. Home fires ~6 of these in parallel and waits for the slowest (worst case ~7s in Sentry). With no loading state, Home shows "No recent expenses" for that entire window.

Backend was ruled out — every Search call returned 200 with the expected results; this is a frontend state/UX issue.

Proposed changes

  1. Never show the empty state when local data exists. The widget should fall back to existing local expense data while a Search is running or has failed, and only show "No recent expenses" on a genuine first sign-in with no data.
  2. Add a loading state so Home doesn't assert "no expenses" while Search is still in flight.
  3. Reduce the payload — the widget only renders 5 rows, so the Search should request ~5 transactions instead of 51 to shrink the payload (may not speed up the query much, but avoids the unnecessary transfer).

cc @adhorodyski @BartekObudzinski @adamgrzybowski @grgia

Reported in Slack.

Issue OwnerCurrent Issue Owner: @mallenexpensify

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Aug 18, 2026
  2. melvin-bot commented on Aug 19, 2026

    @melvin-bot
    Author

    @mountiny — to hire @Eskalifer1 on Upwork, add the External label so a job is created and the offer is sent automatically.

  3. changed the title [-]Home "Recently added" widget shows "No recent expenses" when the Search request fails or is still in flight[/-] [+][Due for payment 2026-09-01] Home "Recently added" widget shows "No recent expenses" when the Search request fails or is still in flight[/+] on Aug 25, 2026
  4. 3 remaining items

  5. Eskalifer1 commented on Aug 31, 2026

    @Eskalifer1
    Contributor

    @MelvinBot find offending PR for this issue based on changes from PR

  6. MelvinBot commented on Aug 31, 2026

    @MelvinBot
    Contributor

    Offending PR: #93451 — [Home Page] Add Recently added slot to Home

    Merged 2026-06-19 by adamgrzybowski. It introduced the Recently added slot with only two render states — rows or "No recent expenses" — while sourcing its data from an async Search snapshot. Every "no expenses" symptom in this issue comes from that gap, so both root causes trace back here.

    Root cause 1 — failed Search wipes the section. The slot rendered index.tsx:145-183 as hasExpenses ? rows : <EmptyState />, and only refetched on focus or hash change (useRecentlyAddedData.ts:101-106). A single failed request therefore emptied it indefinitely.

    Root cause 2 — no loading state. Same two-state render: an in-flight Search was indistinguishable from having no expenses.

    Why the Search data layer is not the offending PR

    The Search failure path deletes the snapshot's data at Search.ts:820. That behavior predates this issue by ~18 months — it was added in #54007 (2024-12-20) so the Search page would show its empty view on error, and later hardened to data: null in #82255. It was correct for its only consumer at the time and caused no user-visible bug on its own.

    #93451 made a second consumer depend on that snapshot without accounting for the wipe or for the in-flight window. That is where the reported regression enters production, so it is the PR to attribute.

    git log -L on the failure block confirms the ordering:

    751fc58 2026-04-14  data: {} -> data: null      (PR #82255)
    d667407 2024-12-12  introduced data: {}          (PR #54007)
    

    Fixed in #98969, which added isAwaitingFirstResult plus a skeleton (index.tsx:131) and stopped deleting data on failure in getOnyxLoadingData.

    💡 Suggested AI code review rule

    This looks like a recurring, mechanically detectable pattern, so it may be worth a coding-standards rule. Proposed for Expensify/App:

    • Rule: UI-4 Do not render an empty state from async data without a settled signal
    • Condition: A component renders an empty/zero state gated only on data.length (or isEmptyObject(data)) while that data comes from an async source such as a Search snapshot or a request-backed useOnyx key. Require an explicit "the outcome is settled" flag and render a skeleton until then; never let in-flight or failed resolve to the same UI as genuinely empty.
    • Why: Loading and error collapse into "you have nothing", so the app confidently asserts a falsehood about the user's data. That is what produced this issue — users with plenty of expenses were shown "No recent expenses" for 30+ minutes.
    • Search pattern: grep -rnE '(\.length (>|===) 0|isEmptyObject\()[^\n]*\?' src/ on files that also match SNAPSHOT|useOnyx, then check for a loading/settled branch.
    • Offending code (❌): index.tsx:145-183
    • Fix (✅): index.tsx:131

    No existing rule covers this — UI-1 is about which loading indicator to use, not about missing one. If it's worth adding, a maintainer can open it as a draft PR in Expensify/App.


    view run

  7. Eskalifer1 commented on Aug 31, 2026

    @Eskalifer1
    Contributor

    Contributor+ Checklist:

    • [Contributor] The offending PR and associated issue have been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

      Link to the comment on the PR: [Home Page] Add Recently added slot to Home #93451 (comment)

    • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.

      Link to discussion: N/A

    • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

    Regression Test Proposal

    Precondition:

    • Sign in to an account that has several expenses.

    Test:

    1. Go to Settings > Troubleshoot and tap Reset and refresh, then open Home.
    2. Verify the Recently added section shows a shimmer placeholder first and then the real rows
    3. Let the section fill, then toggle on Simulate failing network requests
    4. Leave Home (for example open Search) and come back, which forces a refetch that now fails.
    5. Verify the rows are still on screen.

    Do we agree 👍 or 👎

  8. melvin-bot commented on Aug 31, 2026

    @melvin-bot
    Author

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  9. melvin-bot commented on Aug 31, 2026

    @melvin-bot
    Author

    Payment Summary

    Resolving PRs:

    BugZero Checklist (@mallenexpensify)

    • I have confirmed assignees, roles, and Upwork contracts look correct
    • I have paid out Upwork contracts / manual NewDot requests
    • [BugZero Assignee] I have created a GH issue for creating/updating the regression test once above steps have been agreed upon
  10. mallenexpensify commented on Sep 3, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @Eskalifer1 paid $250 via Upwork.

    @Eskalifer1 can you please accept the job below? Please reply here and tag me once you have.
    https://www.upwork.com/jobs/~022095584032299760681

  11. Eskalifer1 commented on Sep 3, 2026

    @Eskalifer1
    Contributor

    Hi @mallenexpensify, i have accepted, thank you!

  12. mallenexpensify commented on Sep 3, 2026

    @mallenexpensify
    Contributor

    @Eskalifer1 paid, summary updated above. Thx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.WeeklyKSv2

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions