Fixed held expense disappearing after approving pending expense from Reports#57887
Conversation
|
@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] |
|
All contributors have signed the CLA ✍️ ✅ |
|
I have read the CLA Document and I hereby sign the CLA |
Screenshots🔲 iOS / native🔲 iOS / Safari🔲 MacOS / Desktop🔲 MacOS / Chrome🔲 Android / Chrome🔲 Android / native |
|
I am currently looking at the performance impact of this solution, and it seems that it might not be the best solution as our reports can change very often in the background. So if a user is looking at transactions and a new message arrives at the back, we do not want to rerun the search. This is just unnecessary. We might have to optimize this @LorenzoBloedow? Unfortunately, I overlooked this during the proposal review. |
@parasharrajat No worries, just pushed a commit that constrained the if statement to the previous behavior or an IOU change. |
There was a problem hiding this comment.
I didn't understand this. What are we trying to accomplish here exactly?
There was a problem hiding this comment.
When we pay the expense (that may contain a held expense), an IOU event is triggered and added to the end of the array.
We still need to trigger the search when this happens in order to fix the bug, but now we're limiting the amount of times that search is triggered.
There was a problem hiding this comment.
But it's not the proper way bcz there can be other IOU on in the actions.
There was a problem hiding this comment.
You're right, that wasn't the best solution.
Updated the code to only trigger when the search when the user actually clicks the pay button.
Is this better?
|
@parasharrajat Can you please review the new changes addressing the performance concerns? Thanks :) |
|
I wil review this asap. |
|
Looks like we have completely detoured from the original solution. I am will take a look at the issue again and see what should be done here. I wan't much active last week. |
I don't think there's much that can be done to optimize the original solution but I can take a look at it again if we should stick to it. Performance-wise, I think the current solution is the best though as it only triggers the search once. |
|
Thanks for waiting. I am back on it. I will for sure update this PR tomorrow morning (12 hours from now.). |
|
@parasharrajat Could you please take a look at this PR when you have a moment? |
|
Thanks for the reminder. Apologies for this delay, I will try to get some time for this. I am not 100% up with your solution that's why I can't directly jump to the review part. First we need to finalized the solution. |
No worries =)
Do you mean you don't understand it? If so, here's a brief explanation: Given your concerns about the original solution’s performance, the latest solution does the following:
This solution fixes both the performance problem and a previous race condition where if you click "Submit" too fast the search isn't triggered. I have to admit I'm a little confused on what I should do so we can move this forward 😅, is there anything you'd like me to change about this solution? Thanks for your patience =) |
|
I will probably review this EOD and try to unblock. Thanks for waiting. |
|
Looking it now. |
parasharrajat
left a comment
There was a problem hiding this comment.
I don't think we should trigger the search from the report page. Technically, there should not be any need to do so as we can use Onyx keys to check and trigger search.
Also, we should keep the search functionality within its scope.
|
Based on the recent changes, I can that the our initial solution was already implemented in a different PR. I am currently validating that solution if that is accepted, we don't need to make any change here. This issue will be considered done. |
Let me know how that goes, should we continue here, I'll make sure to switch to the original solution and find a way to fix the race condition and multiple requests from the original solution as that's why we switched to the current one. |
|
I was taking a look at the recent changes, and though the core issue might be fixed, we could use this PR to improve it, because, as you mentioned here:
If it still has the same performance issues, maybe it's not the best solution. |
|
That works for me. I am waiting for the discussion on that solution to conclude. Once finalized, I will let you know. |
|
So I have not got any objections on that solution so far. Let's see if we can improve the original solution here and wrap this one. |
|
Yes, please migrate only the files that you have modified originally in the source. Leave others.
|
|
@blimpich Sorry about that, reading back, I probably should've been clearer how I was proposing fixing all linter errors specifically from Reverted the changes and migrated only the necessary files, everything should be passing now :) |
|
@blimpich looks like this was merged without a test passing. Please add a note explaining why this was done and remove the |
|
Not an emergency, silly linter was complaining about files that we didn't touch in this PR. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
Interesting, might have to do with the state of the git tree before reverting. Now that my first PR has been merged, according to the contributing guidelines, I'm assuming it's ok for me to potentially work on multiple PRs at the same time, or do I have to wait for something else? @blimpich Also, thanks for all the help everyone! |
|
Yup! All good to work on as many issues as you want! Nexts steps here are:
Thank you for contributing! 🙂 |
|
@LorenzoBloedow This PR is failing because of issue #62042 Bug6831312_1747245700219.bandicam_2025-05-14_19-50-48-199.mp4 |
|
That is unrelated to this PR @nlemma |
|
I might be missing something, but is step 13 expected to behave this way? |
|
I didn't notice the steps on this PR due to time lag. They might be outdated as a lot has changed since this PR was created. We didn't change any code in this PR, so this PR can't cause that issue. Please confirm internally whether step 13 is expected or not. Don't rely on these steps. |
|
It looks like both issues have the same underlying problem. If you agree, this could be tracked and be fixed as part of #57605 |
|
They don't seem to have the same root problem, but they are indeed similar, if needed I can work on it, just need some help on how to proceed in regards to where the work should be done since this PR was already merged. |
|
@LorenzoBloedow In this case, you can create another PR to solve that. |
|
@parasharrajat Looks like the issue comes from a recent PR in staging, I asked whether we should revert it or open a new PR here. |
|
Thanks for digging that up. I agree with you reopening that issue |

Explanation of Change
Make sure search is triggered when approving an IOU with a held expense.
Fixed Issues
$ #57605
PROPOSAL: #57605 (comment)
Tests
Pretty much same as QA:
Offline tests
Same as tests
QA Steps
Same as tests
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
Android: Native
Screen.Recording.2025-03-05.at.5.41.54.PM.mov
Android: mWeb Chrome
Screen.Recording.2025-03-05.at.5.24.58.PM.mov
iOS: Native
Screen.Recording.2025-03-05.at.5.54.29.PM.mov
iOS: mWeb Safari
Screen.Recording.2025-03-05.at.5.04.27.PM.mov
MacOS: Chrome / Safari
Screen.Recording.2025-03-05.at.4.53.02.PM.mov
MacOS: Desktop
Screen.Recording.2025-03-05.at.5.58.18.PM.mov
Unrelated errors:

PS: It seems there's an unrelated race condition on mobile where if you click "Submit" too fast the search isn't triggered, this should probably be a new issue.Fixed with cfa0ed3.