Fix default ordering of data when switching between views and group-bys#82264
Conversation
…e that UI passes query params in valid order
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
view:line is used|
@ShridharGoel 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] |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d9123ff4a6
ℹ️ 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".
joekaufmanexpensify
left a comment
There was a problem hiding this comment.
Good for product
src/libs/SearchQueryUtils.ts
Outdated
| /** | ||
| * Determines whether sortOrder should be reset (not passed to query builder) when filters change. | ||
| * Line view uses sortOrder:asc for time-based groupBy, which differs from other views. | ||
| * When crossing the line/non-line boundary or changing groupBy within line view, |
There was a problem hiding this comment.
This might need an update, since it now resets on any view or groupBy change
|
🚧 @trjExpensify 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! 🧪🧪
|
|
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppiOS: mWeb Safari |
|
Bug: Screen.Recording.2026-03-04.at.5.44.12.PM.mov |
Fixed this one |
|
Can we add a test to cover this in |
|
We did not find an internal engineer to review this PR, trying to assign a random engineer to #82265 as well as to this PR... Please reach out for help on Slack if no one gets assigned! |
Agree! I'll do that shortly Also I noticed failing jest tests: https://github.com/Expensify/App/actions/runs/22669907700/job/65711007591?pr=82264 It looks like it's not coming from our PR so I will merge latest main and hopefully it will fix the issue |
|
🚧 @puneetlath has triggered a test Expensify/App build. You can view the workflow run here. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
stitesExpensify
left a comment
There was a problem hiding this comment.
Nice, looks great!
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/puneetlath in version: 9.3.32-0 🚀
|
|
🚀 Deployed to production by https://github.com/blimpich in version: 9.3.32-3 🚀
|



Explanation of Change
Previously, chart view defaults (
groupBy,sortOrder) were computed outside the parser ingetChartViewDefaults()and applied viaObject.assign. This worked but was inconsistent with how other defaults (e.g.sortBy/sortOrderforgroupBychanges) are handled, those live in the parser'supdateDefaultValues.This PR:
updateDefaultValues, when a non-table view is set, the parser derives defaultgroupBy,sortBy, andsortOrderdirectlysortOrdertoascfor all non-table views with time-basedgroupBy(week, month, year, quarter). Nevertheless, it won't impactPieChartas it internally sorts data by group's absolute value to show pie slices in decreasing angle order. I.e.PieChartalways ignoressort-orderno matter if it'sdescorasc.shouldResetSortOrderto trigger on any view or groupBy change, ensuring each context gets its correct defaultbuildQueryStringFromFilterFormValues,groupBy/viewnow come beforesortBy/sortOrder, which ensures correct parser defaults for UI-constructed queriesFixed Issues
$ #82265
PROPOSAL:
Tests
Defaults for chart views (new behavior: all non-table views with time-based groupBy default to sortOrder:asc):
type:expense view:barin Search — verify the results are sorted ascendingtype:expense view:linein Search — verify the chart shows data ascendingtype:expense view:bar groupBy:week— verify results are sorted ascendingtype:expense view:bar groupBy:withdrawal-id— verify results are sorted descending (non-time groupBy keeps its natural default)View transitions via SearchFiltersBar (quick selectors):
5. Type
type:expense view:bar— verify sortOrder is asc, groupBy defaults to category, sortBy defaults to groupCategory6. Switch to line view — verify sortOrder stays asc, groupBy stays category, sortBy stays groupCategory
7. Switch back to table view — verify sortOrder stays asc, sortBy stays groupCategory (groupBy:category persists)
8. In table view, manually set sortOrder to desc. Switch to bar view — verify sortOrder resets to asc (not inherited from table)
9. In table view, manually set sortOrder to asc. Switch to bar view — verify sortOrder stays asc
GroupBy transitions via SearchFiltersBar:
10. In bar view, change groupBy from category to week — verify sortOrder stays asc, sortBy changes to groupweek
11. Change groupBy to withdrawal-id — verify sortOrder changes to desc, sortBy changes to groupWithdrawn
12. Change groupBy back to month — verify sortOrder changes to asc, sortBy changes to groupmonth
View transitions via Advanced Search Filters:
13. Open Advanced Search Filters
14. Set view to line — verify sortOrder is asc, groupBy is month, sortBy is groupmonth
15. Change view to bar — verify sortOrder stays asc, groupBy stays month, sortBy stays groupmonth
16. Change view to table — verify sortOrder resets to desc, sortBy stays groupmonth
GroupBy transitions via Advanced Search Filters:
17. Set view to bar, groupBy to week — verify sortOrder is asc, sortBy is groupweek
18. Change groupBy to category — verify sortOrder is asc (category's natural default), sortBy changes to groupCategory
19. Change groupBy to withdrawal-id — verify sortOrder changes to desc, sortBy changes to groupWithdrawn
Explicit sortOrder is respected:
20. Type
type:expense view:line sortOrder:desc— verify data is sorted descending (newest first), not overridden to asc21. Type
type:expense view:bar groupBy:week sortOrder:desc— verify data is sorted descendingTable view unchanged:
22. Type
type:expense groupBy:week(no view, defaults to table) — verify sortOrder is desc23. Type
type:expense groupBy:category(table view) — verify sortOrder is asc (category's natural default, same as on main)Offline tests
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
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari