Update hold flow on the search page#49003
Conversation
| function holdMoneyRequestOnSearch(hash: number, transactionIDList: string[], comment: string) { | ||
| const {optimisticData, finallyData} = getOnyxLoadingData(hash); | ||
|
|
||
| optimisticData.push({ |
There was a problem hiding this comment.
We need failureData too in case the API request doesn't succeed.
There was a problem hiding this comment.
I think we should probably also:
There was a problem hiding this comment.
@jjcoffee If we add a comment to the report optimistically, the backend returns the same comment, resulting in a duplicate. To do that, we need to update the backend to return the same optimistic reportActionID so that we no longer get a duplicate comment.
There was a problem hiding this comment.
@jjcoffee I prefer not to add comments optimistically. Do you agree to remove optimistic report action?
There was a problem hiding this comment.
Yeah it doesn't seem useful if it gets duplicated. Let's revert for now whilst we decide on the approach.
|
desktop-chrome-2024-09-18_12.15.55.mp4 |
|
@jjcoffee This is only the draft change to test. If we agree with this approach totally. I will complete the PR and tag you for reviewing |
@jjcoffee For this bug, we're not resetting the selectedTransaction data in the search context when the new value is updated, resulting in outdated information. My solution is to reset the selected transaction whenever the user clicks the hold/unhold option. |
Reviewer Checklist
Screenshots/VideosAndroid: NativeAndroid: mWeb ChromeiOS: NativeiOS: mWeb SafariMacOS: Chrome / SafariMacOS: Desktop |
@cretadn22 By reset, do you mean any selected transaction(s) would be deselected? |
@jjcoffee Yess |
|
@cretadn22 This is maybe a bit of a derail but since this approach is getting quite convoluted, I'm wondering if a simpler approach is to update the |
I'm not sure if that would be expected, but I think we can argue that it's out of scope of this issue since it already happens on main even when just bulk selecting and holding an expense (the dropdown doesn't reflect the updated state). So it's a bit of a separate issue, I think. |
This comment was marked as spam.
This comment was marked as spam.
@jjcoffee Could you please provide a more detailed explanation of this comment? |
|
@cretadn22 The RCA is that the search page header uses a different key ( |
|
@jjcoffee From what I observed, SearchPageHeader only use data from useSearchContext hook. And the data in useSearchContext hook is outdated and caused this problem. Is this what you mean? |
This data originally comes from the
|
I still see that we’re updating the correct Onyx key with the proper hash, but I’m not entirely sure I fully understand your point. To clarify further, could you please share a video that shows this bug? |
|
@cretadn22 I'm proposing an alternative approach, not reporting a bug. So taking a look at these steps:
In step 5 I'm proposing we switch back to using |
|
@jjcoffee Got it, I misunderstood your point earlier. I'll give your new approach a try and give a feedback soon |
|
I just created a new pull request to implement @jjcoffee's approach. I’ll mark it as ready once I’ve thoroughly tested it. If this approach is fine, we can close this one |

Details
Fixed Issues
$ #46524
PROPOSAL: #46524 (comment)
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.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
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
Screen210.mov
MacOS: Desktop