Skip to content

Fix inconsistent Expenses footer behavior when returning from saved search#78398

Merged
yuwenmemon merged 7 commits intoExpensify:mainfrom
marufsharifi:fix/reports-expenses-footer-on-saved-search-return
Jan 22, 2026
Merged

Fix inconsistent Expenses footer behavior when returning from saved search#78398
yuwenmemon merged 7 commits intoExpensify:mainfrom
marufsharifi:fix/reports-expenses-footer-on-saved-search-return

Conversation

@marufsharifi
Copy link
Contributor

@marufsharifi marufsharifi commented Dec 23, 2025

Explanation of Change

Making the footer in the search page consistent before and after saving the search.

Fixed Issues

$ #75042
PROPOSAL: #75042 (Comment)

Tests

Prerequisite: Have a workspace with at least one expense to select during the search filter.

  1. Open the Expensify app.
  2. Navigate to "Reports" > "Expenses."
  3. Note that no footer with the expenses number and total amount is visible.
  4. Tap on "Filters."
  5. Apply any filter that will trigger a result. (For example: Select workspace with expenses on "Workspaces" filter)
  6. Tap on "Save."
  7. Save the search.
  8. Note that when redirected to the triggered search, a footer with the expenses number and total amount appears.
  9. Clear the search from the search input.
  10. Note that you land on "Expenses" again, and no footer with the expenses number and total amount is visible.
  11. Navigate to the saved search again.
  12. While on the saved search, delete it from the left sidebar.
  13. When redirected to "Expenses" again, note that now, the footer is not visible anymore.
  14. The footer in the expense should be consistent before and after saving the search.
  • Verify that no errors appear in the JS console

Offline tests

Same as Tests

QA Steps

Same as Tests

// TODO: These must be filled out, or the issue title must include "[No QA]."

  • 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 verified there are no new alerts related to the canBeMissing param for useOnyx
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • 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 shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • 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)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • 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)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • 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.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • 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-native.mov
Android: mWeb Chrome
android-web.mov
iOS: Native
ios-native.mov
iOS: mWeb Safari
ios-web.mov
MacOS: Chrome / Safari
desktop.mov

@marufsharifi marufsharifi requested review from a team as code owners December 23, 2025 18:48
@melvin-bot melvin-bot bot requested review from parasharrajat and removed request for a team December 23, 2025 18:48
@melvin-bot
Copy link

melvin-bot bot commented Dec 23, 2025

@parasharrajat 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]

@melvin-bot melvin-bot bot requested review from JmillsExpensify, flaviadefaria, heyjennahay, joekaufmanexpensify and trjExpensify and removed request for a team December 23, 2025 18:48
@codecov
Copy link

codecov bot commented Dec 23, 2025

Codecov Report

✅ Changes either increased or maintained existing code coverage, great job!

Files with missing lines Coverage Δ
src/libs/SearchQueryUtils.ts 69.64% <100.00%> (ø)
src/pages/Search/AdvancedSearchFilters.tsx 0.00% <0.00%> (ø)
... and 11 files with indirect coverage changes

@parasharrajat
Copy link
Member

BUG: Expenses footer does not show consistently when we add a new workspace filter.

Steps:

  1. Open reports page.
  2. Clear all filters and remove all saved searches.
  3. in the search input type workspace:any workspace.
  4. Click filter and saved that filter.
  5. Wait for expenses footer to show up.

Expected: Footer should stay.

@marufsharifi
Copy link
Contributor Author

BUG: Expenses footer does not show consistently when we add a new workspace filter.

Steps:

  1. Open reports page.
  2. Clear all filters and remove all saved searches.
  3. in the search input type workspace:any workspace.
  4. Click filter and saved that filter.
  5. Wait for expenses footer to show up.

Expected: Footer should stay.

@parasharrajat, thanks for the review. I’ve tested this multiple times using your steps but haven’t been able to reproduce the issue. Could you please share a recording? There might be something I’m missing in my testing.

@parasharrajat
Copy link
Member

parasharrajat commented Dec 26, 2025

Here is the vid, check when I save the filter, the footer shows momentarily.

26.12.2025_13.59.07_REC.mp4

@marufsharifi
Copy link
Contributor Author

@parasharrajat, can you please take a look at what happens on my side? It briefly shows the footer before saving the filter. After saving the filter, it displays correctly.

expense-footer.webm

What is the expected behavior here? Should the footer be shown before save or not?

@parasharrajat
Copy link
Member

Ok. So footer should not be shown when filter is added. It should only be shown when we are looking at saved search as per the logic. So if the logic is saying so, the ui should behave same.

If I am getting different results than you then there is still some inconsistency.

@marufsharifi
Copy link
Contributor Author

@parasharrajat, thanks i am working on a fix.

@parasharrajat
Copy link
Member

Thanks for the details. Feel free to use Slack to discuss this if needed.

@parasharrajat
Copy link
Member

any updates here?

@marufsharifi
Copy link
Contributor Author

@parasharrajat, thanks for the review. I am working on this. I will update the PR today.

Copy link
Contributor

@trjExpensify trjExpensify left a comment

Choose a reason for hiding this comment

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

The lack of an explanation of changes and the test steps reading like a bug report in this PR make it hard to evaluate what exactly is being changed.

@marufsharifi
Copy link
Contributor Author

@parasharrajat, thanks for the feedback.

If both params are the same, why does the response differ?

The parameters are actually different:

  1. In one case, shouldCalculateTotal is set to false.
  2. In the other, shouldCalculateTotal is set to true.

Savedsearch api's task is to save search not to give results. Other one is for searching the data which controls whether footer should be shown or not.

The SavedSearch API is called, followed by two Search API calls with different parameters.

Search is changed, search api is called again. Here it should decide whether we want to get the count or not which is control by the hook.

The Search API is triggered after DeleteSavedSearch completes. At that point, the hook determines whether the count should be fetched. However, since the updated Search API response isn’t available immediately, the footer is shown right away due to stale data still present in Onyx.

The bug I reported was that when I just create a saved search, the footer gets visible then hides. Is this bug happening because of the race conditions?

No, this happens because stale data remains in Onyx after the saved search is deleted.

@parasharrajat, let me know if you need any more details. Thanks!

@parasharrajat
Copy link
Member

parasharrajat commented Jan 11, 2026

In one case, shouldCalculateTotal is set to false.
In the other, shouldCalculateTotal is set to true.

why the hook giving 2 different values? I beleive in both API calls we are passing value of this flag from the hook...

No, this happens because stale data remains in Onyx after the saved search is deleted.

Then I still don't understand how... Why do you think the delete saved search Api should control the visibility of footer?

When search is deleted, we make a new search call which should determine whether the new search needs to show the footer or not.

The Search API is triggered after DeleteSavedSearch completes. At that point, the hook determines whether the count should be fetched. However, since the updated Search API response isn’t available immediately, the footer is shown right away due to stale data still present in Onyx.

But I don't think that this is a issue. Search is deleted footer remains until new data comes from new search API call. What is wrong with this?

also, How this problem is related to the bug? Our bug is happening when we create a new search not when we delete it.

@marufsharifi
Copy link
Contributor Author

why the hook giving 2 different values? I beleive in both API calls we are passing value of this flag from the hook...

This happens because of the race condition the onyx data is not updated, and the page re-renders and calls the Search API. Then, after onyx udpdates the hooks return different response and call the Search again.

Then I still don't understand how... Why do you think the delete saved search Api should control the visibility of footer?

So, do you recommend to update the onyx optimistic data when calling the Search API? This will resolve the issue it remove stale data before BE response comes.

But I don't think that this is a issue. Search is deleted footer remains until new data comes from new search API call. What is wrong with this?

If we update the onyx data before the BE response comes this will not be an issue do you recommend it?

How this problem is related to the bug? Our bug is happening when we create a new search not when we delete it.

We need to update the onyx data before the saveSearch data comes, either when deleting a saved Search or calling the Search API. When there is no saved search the footer is filtered by other conditions, but after we call Search those gets resolved and the onyx data has count property which is stale, so it shows the footer until the BE response comes and update the Onyx, which will remove the count.

@parasharrajat, if anything is still unclear, please let me know. I can share screenshots or recordings to help clarify what’s happening. Thanks!

@parasharrajat
Copy link
Member

We need to update the onyx data before the saveSearch data comes, either when deleting a saved Search or calling the Search API. When there is no saved search, the footer is filtered by other conditions, but after we call Search, those get resolved, and the Onyx data has a count property, which is stale, so it shows the footer until the BE response comes and updates the Onyx, which will remove the count.

This still does not answer how this is related to the bug I reported. You are talking about a delete scenario, and I am talking about a create.

@marufsharifi
Copy link
Contributor Author

@parasharrajat, could you please take a careful look at the following video?

Here’s what’s happening step by step:

  1. After saving a search, the Search API is called for a specific hash, and the response includes Count: number, which gets stored in Onyx.
  2. When the saved search is deleted, the Search API is called again, but this time for a different hash. However, the previously stored Count: number remains in Onyx, so it becomes stale.
  3. At this point, the footer is hidden because we are no longer rendering search results for the original hash.
  4. Later, when a new search is created but not saved (only viewed), we render results for that same hash again, using the stale Onyx data. This causes the footer to appear immediately.
  5. Once the Search API response for this hash arrives from the backend, it does not include Count: number. Onyx is then updated accordingly, and the footer gets hidden again.
Screen.Recording.1404-10-22.at.4.12.16.PM.mp4

@parasharrajat, If it was still unclear, please let me know. thanks

@parasharrajat
Copy link
Member

Checking...

@marufsharifi
Copy link
Contributor Author

@parasharrajat, kindly bump. thanks

@marufsharifi
Copy link
Contributor Author

@parasharrajat, quick bump. thanks

@parasharrajat
Copy link
Member

I will check in the evening.

@parasharrajat
Copy link
Member

@marufsharifi Can you please merge main? I can't test without it.

@marufsharifi
Copy link
Contributor Author

@parasharrajat, thanks for the review. I merged the main; the pr is ready for your review.

@parasharrajat
Copy link
Member

parasharrajat commented Jan 22, 2026

I can confirm this #78398 (comment). Let's leave this to @yuwenmemon to confirm whether this is a problem.

IMO, it is not a big deal that the footer hides once data is returned from the backend, so it is acceptable.

Other than this, we solved what was requested in the issue.

@parasharrajat
Copy link
Member

parasharrajat commented Jan 22, 2026

Screenshots

🔲 iOS / native

22.01.2026_17.43.33_REC.mp4

🔲 iOS / Safari

22.01.2026_17.31.18_REC.mp4

🔲 MacOS / Chrome

22.01.2026_16.36.07_REC.mp4

🔲 Android / Chrome

🔲 Android / native

22.01.2026_17.21.03_REC.mp4

Copy link
Member

@parasharrajat parasharrajat left a comment

Choose a reason for hiding this comment

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

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 tests pass on all platforms & I tested again on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
    • MacOS: Desktop
  • 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 any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • I verified that the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • 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 shown in the product is localized by adding it to src/languages/* files and using the translation method
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • 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 approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • 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)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • 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
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • 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 any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • 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 form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • 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.

🎀 👀 🎀 C+ reviewed

@melvin-bot melvin-bot bot requested a review from yuwenmemon January 22, 2026 12:18
@parasharrajat
Copy link
Member

@yuwenmemon a comment for you #78398 (comment)

@yuwenmemon
Copy link
Contributor

@parasharrajat @marufsharifi It's not ideal, but I agree it can be fixed in a follow-up.

@yuwenmemon yuwenmemon dismissed trjExpensify’s stale review January 22, 2026 18:39

Tom's feedback was addressed

@yuwenmemon yuwenmemon merged commit 9c46002 into Expensify:main Jan 22, 2026
31 checks passed
@OSBotify
Copy link
Contributor

🚀 Deployed to staging by https://github.com/yuwenmemon in version: 9.3.7-0 🚀

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

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/Beamanator in version: 9.3.7-3 🚀

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

@marufsharifi
Copy link
Contributor Author

marufsharifi commented Feb 5, 2026

@parasharrajat @marufsharifi It's not ideal, but I agree it can be fixed in a follow-up.

@parasharrajat, should I raise a follow-up PR based on this? Thanks.

cc @yuwenmemon

@yuwenmemon
Copy link
Contributor

Yes, if you could.

@marufsharifi
Copy link
Contributor Author

@parasharrajat , I raised the follow-up pr and fixed it. Could you please check and, if possible, share the docs for this kind of tasks, what is the process? thanks.

cc @yuwenmemon

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.

5 participants