Skip to content

fix: Recently added section shows false empty state on Home - #98969

Merged
mountiny merged 17 commits into
Expensify:mainfrom
callstack-internal:fix/recently-added-false-empty-state
Aug 24, 2026
Merged

mountiny merged 17 commits into
Expensify:mainfrom
callstack-internal:fix/recently-added-false-empty-state

Conversation

@BartekObudzinski

@BartekObudzinski BartekObudzinski commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

Home's "Recently added" section was telling users with plenty of expenses that they had none. Two client-side bugs caused this, both fixed here.

First, when a Search request fails while online, the failure path deletes the stored snapshot's data outright, and the section only refetches when Home regains focus or the query changes. A user sitting on Home lost their rows to a single failed request and was shown "no recent expenses" for over half an hour in one production case. The hook now remembers the last snapshot data it rendered, paired with the query hash it was fetched for, and falls back to that copy only while errors are latched. The hash pairing matters because a delegate switch clears Onyx without unmounting Home, so an unkeyed copy could render the previous account's expenses.

Second, the section only had two states: rows, or the empty message. An in-flight or failed search looked identical to a user with no expenses. It now exposes isAwaitingFirstResult and renders a skeleton until the outcome is settled. Note for reviewers: search.state reaches loaded even for failures, so the error case is detected from errors, not from state.

The linked issue also suggests capping the query at roughly 5 rows since the section renders at most 5. That is not safely implementable today and is deliberately left out: the parser sends this query as sortBy: date, so a server-side cap truncates by expense date, while the section orders by insertion time. There is no insertion-time sort column in CONST.SEARCH.SORT_BY_COLUMNS, so a backdated or imported expense added today could be cut before the section ever sorts. Worth tracking separately on the issue.

The backend was ruled out during diagnosis: every Search call returned 200 with the expected, byte-identical results.

Note for reviewers: there's a cleaner fix for the first bug that belongs in the Search data layer rather than in this widget. The failure path deletes the snapshot's data even though the error is already recorded separately in errors. Leaving the data alone would keep the snapshot as the single source of truth and would protect every other Search consumer, not just this widget. It's out of scope here because it changes shared behavior for the Search page itself, which branches on data presence, so it needs sign-off from a Search owner.

Fixed Issues

$ #98895
PROPOSAL:

Tests

  1. Sign in to an account that has several expenses.
  2. Go to Settings > Troubleshoot and tap Reset and refresh, then open Home.
  3. Verify the Recently added section shows a shimmer placeholder first and then the real rows. It must never show "No recent expenses" while the search is still running.
  4. Verify the widget does not grow and push the rest of Home down when the rows appear. Check this in both a wide and a narrow window.
  5. Let the section fill, then block */api/Search* in the browser devtools Network tab.
  6. Leave Home (for example open Search) and come back, which forces a refetch that now fails.
  7. Verify the rows are still on screen. They must not be replaced by "No recent expenses".
  8. Press F5 to reload the page with the request still blocked, and verify the rows are still there after the reload.
  9. Unblock the request, then go offline and back online while the section shows its error, and verify the search retries automatically rather than waiting for a manual Try again.
  • Verify that no errors appear in the JS console

Offline tests

  1. Load Home while online so the Recently added section fills.
  2. Turn on Force offline in Settings > Troubleshoot, then return to Home.
  3. Verify the rows stay visible and the section does not claim there are no expenses.
  4. Turn Force offline back off and verify the section refreshes normally.

QA Steps

Same as tests

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
Screen.Recording.2026-08-19.at.15.43.48.mov
iOS: mWeb Safari
MacOS: Chrome / Safari
Screen.Recording.2026-08-19.at.14.42.21.mov

@codecov

codecov Bot commented Aug 19, 2026 •

Copy link
Copy Markdown

@BartekObudzinski
BartekObudzinski marked this pull request as ready for review August 19, 2026 13:46
@BartekObudzinski
BartekObudzinski requested review from a team as code owners August 19, 2026 13:46
@melvin-bot
melvin-bot Bot requested a review from Eskalifer1 August 19, 2026 13:46
@BartekObudzinski

Copy link
Copy Markdown
Contributor Author

@codex review

@melvin-bot
melvin-bot Bot requested review from garrettmknight and removed request for a team and Eskalifer1 August 19, 2026 13:46
@melvin-bot

melvin-bot Bot commented Aug 19, 2026

Copy link
Copy Markdown

@Eskalifer1 Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@mountiny
mountiny requested a review from Eskalifer1 August 19, 2026 13:51
Comment thread src/libs/actions/Search.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3975881f2a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/libs/actions/Search.ts Resolved
Comment on lines 117 to 122
buildQueryStringFromFilterFormValues({
type: CONST.SEARCH.DATA_TYPES.EXPENSE,
from: [String(accountID)],
// Without this the server returns its default page (~50 rows), which is wasted payload for a 5 row slot.
limit: FETCH_LIMIT,
}),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid capping before the insertion-time sort

For users who recently add backdated/imported expenses, this capped query can omit the actual most recently added rows: the parser defaults this Search query to sortBy: date sortOrder: desc, so the server returns only the 15 newest expense dates, and then this hook sorts that already-truncated set by inserted. Any newly inserted expense with an older expense date, or valid row beyond 15 after the client-side filters below, never reaches the widget even though it could have been included in the previous 50-row default page.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, and it goes further than the ordering mismatch. There is no insertion time sort column in CONST.SEARCH.SORT_BY_COLUMNS, so any server side cap truncates by expense date while this section orders by insertion time. That makes the cap unsafe at any size, not just at 15. I removed the limit rather than raising it, since getting the most recently added rows right matters more than the payload saving. The payload idea comes from the linked issue, so I will note there that it needs an insertion time sort before it can be done safely.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this done?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. The query has no limit parameter now. The slice(0, CONST.HOME.SECTION_VISIBLE_LIMIT) that remains is a display cap on the client-side sorted result, not on what the server returns.

@Eskalifer1 Eskalifer1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the first search fails and no snapshot was cached (e.g. right after "Reset and refresh"), hasSearchErrors makes isAwaitingFirstResult false and the section renders "No recent expenses" — the exact false claim the linked issue asks to remove ("only show 'No recent expenses' on a genuine first sign-in with no data"), with no retry until Home is refocused. An error/retry state for the error branch would close this - but i think it's out of the scope

Comment thread src/libs/actions/Search.ts Outdated

@Eskalifer1 Eskalifer1 Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isOffline is now dead in search(): after it stopped being passed to getOnyxLoadingData, the only thing left is forwarding it to search()'s own recursive call, which also does nothing with it. Callers (including the new useRecentlyAddedData) still pass it and read as if search() handled offline.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, it was dead and I left it that way. Removed the parameter from search() and from every call site. I took it out of the signature first and let the typechecker find the callers, which is also how I caught the ones the upstream merge added, since a text search would have missed them. The offline handling that actually matters stays where it was, in the hook effect that returns early when offline.

@Eskalifer1

Copy link
Copy Markdown
Contributor

Let's resolve codex comments and i will do next round of review and I'll do the next round of reviews tonight

garrettmknight
garrettmknight previously approved these changes Aug 19, 2026

@garrettmknight garrettmknight left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good from a product perspective.

@BartekObudzinski

Copy link
Copy Markdown
Contributor Author

All of this round is pushed, plus a sync with main.

@Eskalifer1 on the first failed load with nothing cached, you are right that the section still shows "No recent expenses" there, and I agree it is out of scope for this PR. Closing it properly needs an error state with a retry, which means new copy in every language, so it belongs as a follow up on the issue rather than widening this one. Everything else you and Codex raised is done: the reconnect path retries after a failure again, the row cap is gone, isOffline is removed from search() and its call sites, and the two comment style nits are fixed.

One thing worth flagging for whoever reviews the Search side. The reconnect fix broadens when a Search refetches: after a failure, coming back online now retries even when the screen is not focused, where before that only happened with no results cached. It is a read command so nothing is overwritten, and it is what the flag was for, but it is shared behaviour so it should be a deliberate call rather than a surprise.

@BartekObudzinski

Copy link
Copy Markdown
Contributor Author

i updated the comment as well

@Eskalifer1 Eskalifer1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those are the only two things I noticed!

@Eskalifer1

Eskalifer1 commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
98969-android-native.mov
Android: mWeb Chrome
98969-android-web.mov
iOS: HybridApp
98969-ios-native.mov
iOS: mWeb Safari
98969-ios-web.mov
MacOS: Chrome / Safari
98969-web-1.mov
98969-web-2.mov

@Eskalifer1

Copy link
Copy Markdown
Contributor

And let's merge main into branch!

@BartekObudzinski

Copy link
Copy Markdown
Contributor Author

main synced

@Eskalifer1

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e47dbbb5c7

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@Eskalifer1 Eskalifer1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@melvin-bot
melvin-bot Bot requested a review from mountiny August 21, 2026 11:28
Comment on lines 117 to 122
buildQueryStringFromFilterFormValues({
type: CONST.SEARCH.DATA_TYPES.EXPENSE,
from: [String(accountID)],
// Without this the server returns its default page (~50 rows), which is wasted payload for a 5 row slot.
limit: FETCH_LIMIT,
}),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this done?

@BartekObudzinski

Copy link
Copy Markdown
Contributor Author

All feedback is addressed in the latest commits @mountiny

@mountiny mountiny left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok thank you, lets give this one a go

@mountiny
mountiny merged commit c428e4b into Expensify:main Aug 24, 2026
35 of 36 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🚧 mountiny has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify OSBotify mentioned this pull request Aug 24, 2026
77 tasks done
@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/mountiny in version: 9.4.60-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor

🤖 No help site changes required.

I reviewed this PR against App/docs/articles and no updates are needed.

This is a client-side bug fix for the Recently added section on Home. It (1) shows a loading placeholder while the search resolves instead of a false "No recent expenses" message, and (2) keeps the existing rows on screen when a Search request fails. It adds no new feature, setting, label, or documented behavior.

The section is already documented in Expensify-Home-Overview.md, and that article already describes the correct behavior this PR restores:

Why is the Recently added section empty? The Recently added section always appears on Home. If you haven't added any expenses yet, it shows an empty state.

Since the fix makes the app match what the help site already says (the empty state should only appear when you truly have no expenses), no article is inaccurate. The transient loading placeholder and the error-fallback behavior are internal UI states that help articles don't document.

Because no changes are required, I did not open a draft docs PR.


view run

@IuliiaHerets

Copy link
Copy Markdown

Hi @BartekObudzinski. Steps 5 and 9 are unclear to us. Can the QA team test them?
If not, please share new QA steps. Thanks.

cc @mountiny @garrettmknight @Eskalifer1

@BartekObudzinski

Copy link
Copy Markdown
Contributor Author

Hi @IuliiaHerets, both steps use standard Chrome DevTools capabilities:

Step 5 — open DevTools, go to Network tab, click the request blocking icon (or right-click any api/Search request and pick “Block request URL”), then add the pattern /api/Search.

Step 9 — while the error state is visible, use the Network throttling dropdown in DevTools and switch to “Offline”, then back to “No throttling” to simulate going online.

Both work in Chrome. I didn’t find a way to reproduce the problem using the app directly, so DevTools is the only approach I can suggest here

@mountiny

Copy link
Copy Markdown
Contributor

@IuliiaHerets feel free to check this off, Jason did not run into the original bug so that is promising

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/AndrewGable in version: 9.4.60-2 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants