Add Optimistic Updates to Search Transactions#60189
Conversation
|
@AndrewGable 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] |
Reviewer Checklist
Screenshots/VideosAndroid: NativeAndroid: mWeb ChromeiOS: NativeiOS: mWeb SafariMacOS: Chrome / SafariMacOS: Desktop |
|
✋ 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/AndrewGable in version: 9.1.30-0 🚀
|
|
🚀 Deployed to production by https://github.com/AndrewGable in version: 9.1.30-4 🚀
|
| if (currentSearchQueryJSON && toAccountID != null && fromAccountID != null) { | ||
| const validSearchTypes: SearchDataTypes[] = [CONST.SEARCH.DATA_TYPES.EXPENSE, CONST.SEARCH.DATA_TYPES.INVOICE]; | ||
| const shouldOptimisticallyUpdate = | ||
| currentSearchQueryJSON.status === CONST.SEARCH.STATUS.EXPENSE.ALL && validSearchTypes.includes(currentSearchQueryJSON.type) && currentSearchQueryJSON.flatFilters.length === 0; |
There was a problem hiding this comment.
Skipping the filters here led to this issue #64128 where the query with filters do not get optimistically updated. This is not a mistake, just a case that was not considered before the to do queries are implemented.
|
|
||
| function getCurrentSearchQueryJSON() { | ||
| const rootState = navigationRef.getRootState(); | ||
| const lastPolicyRoute = rootState?.routes?.findLast((route) => route.name === NAVIGATORS.REPORTS_SPLIT_NAVIGATOR || route.name === NAVIGATORS.SEARCH_FULLSCREEN_NAVIGATOR); |
There was a problem hiding this comment.
The addition of the route.name === NAVIGATORS.REPORTS_SPLIT_NAVIGATOR check here led to the following issue:
which we addressed by removing the check (see proposal for details).
Explanation of Change
When scanning receipts, submitting expenses, etc, it takes ~2-3 seconds, maybe more for the search page to refresh, which can be very confusing. In this PR, we add optimistic updates to the search page (exclusively for expenses, reports, invoices), as soon as the expense is added.
Note - Read the issue below. We only are applying optimistic updates when we are viewing all expenses with no filters applied. This is because we need the BE to calculate the search when we have results. For this first PR, we just do expenses with no status/filters.
$ #59947
Tests
Offline tests
QA Steps
Same as above
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))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
Screen.Recording.2025-04-15.at.2.17.29.PM.mov