fix: Deleted expense still visible on chart#82637
fix: Deleted expense still visible on chart#82637cristipaval merged 3 commits intoExpensify:mainfrom
Conversation
Codecov Report❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.
|
| return; | ||
| } | ||
|
|
||
| // If count is already present, the latest response already contains totals and we can skip the re-query. |
There was a problem hiding this comment.
Let's update this comment to take changes from this PR into consideration
|
Alternatively we could omit skipping handleSearch in the previous useEffect, but I guess this logic is there for a reason and we do sometimes show the total and chart together. cc: @ShridharGoel App/src/components/Search/index.tsx Lines 563 to 568 in f56783e |
|
@shubham1206agra 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] |
|
@ChavdaSachin @cristipaval One of you needs to 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] |
|
@ShridharGoel could you review this one? it's chart related + it modifies your recent contribution |
| if (searchResults?.search?.isLoading) { | ||
| if (shouldCalculateTotals && searchResults?.search?.count === undefined) { | ||
| shouldRetrySearchWithTotalsRef.current = true; | ||
| if (validGroupBy || (shouldCalculateTotals && searchResults?.search?.count === undefined)) { |
There was a problem hiding this comment.
❌ CONSISTENCY-5 (docs)
validGroupBy is now referenced inside this useEffect but is not included in the dependency array. The existing eslint-disable-next-line react-hooks/exhaustive-deps (at line 573) suppresses the warning, but the justification comment only explains the omission of isFocused — it does not explain why validGroupBy is intentionally omitted. This means the effect could read a stale validGroupBy value if the group-by selection changes while isLoading is true.
Either add validGroupBy to the dependency array, or update the justification comment to explain why it is safe to omit (e.g., the ref-based retry in the second effect handles changes).
Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
There was a problem hiding this comment.
if validGroupBy changes the queryJson will too, but okay
|
@trjExpensify could we run an ad-hoc build for this PR and ask for a retest? just to make sure this fixes the linked issue, as the modified code fragments were introduced after the issue was raised |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 46913847b7
ℹ️ 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".
|
|
||
| shouldRetrySearchWithTotalsRef.current = false; | ||
| shouldRetrySearchWithTotalsOrGroupedRef.current = false; | ||
| handleSearch({queryJSON, searchKey, offset, shouldCalculateTotals: true, prevReportsLength: filteredDataLength, isLoading: false}); |
There was a problem hiding this comment.
Preserve totals flag when retrying grouped searches
This retry path now always calls handleSearch with shouldCalculateTotals: true, which overrides the value from useSearchShouldCalculateTotals for grouped queries. In the affected flow (for example, returning to a grouped chart while results are still loading), non-eligible searches that intentionally avoid totals aggregation are retried as totals queries, which can add unnecessary backend work and slower responses compared with the original search behavior.
Useful? React with 👍 / 👎.
|
Will start the review soon |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppiOS: mWeb SafariMacOS: Chrome / SafariScreen.Recording.2026-02-17.at.10.20.44.PM.mov |
|
🚧 @cristipaval has triggered a test Expensify/App build. You can view the workflow run here. |
This comment has been minimized.
This comment has been minimized.
|
🚧 @cristipaval has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/cristipaval in version: 9.3.22-0 🚀
|
|
🚀 Deployed to production by https://github.com/mountiny in version: 9.3.22-4 🚀
|
|
🚀 Deployed to production by https://github.com/mountiny in version: 9.3.22-4 🚀
|
Explanation of Change
After deleting an expense and going back to a bar chart, the chart would not update if the results were loading when running the effect handling search in the Search component. This PR updates the logic retrying search to cover this scenario.
Fixed Issues
$ #81110
PROPOSAL: N/A
Tests
skip native iOS mobile as there is no back button/gesture in this scenario
Offline tests
N/A
QA Steps
Same as tests.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Nagranie.z.ekranu.2026-02-17.o.11.17.46.mov
Android: mWeb Chrome
Nagranie.z.ekranu.2026-02-17.o.12.50.07.mov
iOS: Native
iOS: mWeb Safari
Simulator.Screen.Recording.-.iPhone.16.Pro.Max.-.2026-02-17.at.12.39.33.mp4
MacOS: Chrome / Safari
Nagranie.z.ekranu.2026-02-17.o.12.35.02.mov