Fix computing receiver and payer for IOU transaction preview#64228
Conversation
| /** Represents the IOU report entry from Onyx */ | ||
| iouReport: OnyxEntry<Report>; | ||
| /** Represents the report linked to the transaction */ | ||
| report: OnyxEntry<Report>; |
There was a problem hiding this comment.
Why I renamed this prop?
The name iouReport suggests that the report that gets passed is of type IOU. That is not true for the previews and was a source of confusion for me.
Both MoneyRequestReportPreview, and it's children TransactionPreview's can be rendered for both IOU and EXPENSE report.
So in reality this variable can be either expenseReport or iouReport. To make it simpler I just used the name report.
|
|
||
| // For IOU, we want the unprocessed amount, because it is important whether the amount was positive or negative | ||
| // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing | ||
| const transactionRawAmount = (transaction?.modifiedAmount || transaction?.amount) ?? 0; |
There was a problem hiding this comment.
this is the actual heart of the fix - it will pass the unmodified amount, so we will get the positive or negative number and can properly render the from/to arrow
99cf22a to
9d15839
Compare
9d15839 to
7204740
Compare
|
@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] |
|
Testing... |
|
So I can reliably reproduce step 6. @Kicu. Wanna give it another look? |
|
Ok so the immediate cause of the bug from Step 6
is that there happens a refresh of data which breaks the assumption about positive/negative amounts. My hunch is telling me that this happens after we receive the data from the pusher from backend, but I don't yet know how to investigate what data gets pushed and merged to onyx.
vidrec-preview-error.mp4Now I see 2 ways of moving forward:
Regardless I will continue to investigate the refresh problem. |
|
I think its because there are pusher updates missing for when the transaction amounts are swapped, seems like that is the case from a quick look at the command |
|
FYI one related piece of info, there was a PR merge not long ago, that explicitly made so we don't display From/To if there is just one transaction created: #60650 IF it's a BE issue maybe we move forward with reviewing the PR ignoring the refresh problem for now @parasharrajat ? |
|
Sure, let me check. |
|
Yep that is a backend issue so lets please wrap this up @parasharrajat thanks! |
|
Sure |
Screenshots🔲 iOS / native🔲 iOS / Safari19.06.2025_07.05.17_REC.mp4🔲 MacOS / Desktop🔲 MacOS / Chrome19.06.2025_06.59.57_REC.mp4🔲 Android / Chrome19.06.2025_07.03.33_REC.mp4🔲 Android / native |
|
IMO, the arrow direction for split expenses is wrong. In this example, I did split both ways so the overall report total is 0. they canceled out each other. But both split expenses are showing same direction from user A => B. while one of them was created from b => A.
|
|
@parasharrajat is that even after you sign out and sign back in? Are the amounts actually both same sign in onyx? |
|
@mountiny No amount signs are different on both actions. The first one is This is what I see inside the report. Both transactions show $7, which is very confusing. |
|
Yes, On it in 20 mins. |
|
Here are the steps:
Now observe, the report preview. Both transitions show A -> B on both accounts. @Kicu |
|
Alright thanks @parasharrajat I can reproduce that. When we're doing "split" just like you suggested indeed something weird happens with the code. It feels like there is a different dedicated path in the code for this, because my functions are never called with the @mountiny do you perhaps remember anything special related to handling transactions and amounts when the expense is done via |
|
@mountiny When we're rendering Preview for split, we actually pass down not the specific transactions which have - and + signs, but the transaction for the whole split - hence we're actually getting 1200 both times. I can try to work over this, but I'm not sure what is happening around split transactions and what was the intention 🤔 |
|
@parasharrajat Please re-review again. I have fixed the specific case for split request - which was quite confusing :/ Here's the video with my test: rec-splits-preview.mp4 |
|
On, it. There are checks failures. |
|
@parasharrajat all checks are passing 👍 |
|
There is still someting wrong. the A -> B changes values after I create another split transactions.
Check from 0.55 to 1.20 sec. 25.06.2025_18.04.56_REC.mp4 |
|
OK, so a few things here:
The whole thing starts to work once you enter the report and get all the data from backend. rec-splits-bug.mp4CC @mountiny @parasharrajat
|
|
@parasharrajat We can fix the BE now and see if this will be fixed then |
|
So, what do you suggest? Should we go ahead and complete the review here then we can test the split issue when the BE change is made? OR should we hold here until the backend change is done? @mountiny |
|
@parasharrajat you can go ahead and complete the review here |
|
Hello @parasharrajat, I've talked about the issue with @Kicu and tested it against those changes and @mountiny's BE changes. I think everything works fine so we can go forward with this PR: Mateusz+Vit.mov |
@Kicu This is failing on iOS. 27.06.2025_17.56.44_REC.mp4 |
|
@parasharrajat We have discussed multiple times in this thread that anything related to "immediately" displaying is not working because of wrong data from backend. Here: #64228 (comment) In your example on ios if you would enter the actual report and then move back, are the arrows working then? Please just assume that the arrows should be correct AFTER you have entered the actual money request. Anything before that is a backend bug that will be fixed separately. We are running in circles with this bug :| |
|
Oh my bad. I thought I saw it working before, so I raised it. Thanks for confirming. |
Screenshots🔲 iOS / native27.06.2025_20.47.05_REC.mp4🔲 iOS / Safari27.06.2025_20.48.45_REC.mp4🔲 MacOS / Desktop27.06.2025_20.56.23_REC.mp4🔲 MacOS / Chrome27.06.2025_17.52.11_REC.mp4🔲 Android / Chrome27.06.2025_20.49.58_REC.mp4🔲 Android / native27.06.2025_17.53.34_REC.mp4 |
parasharrajat
left a comment
There was a problem hiding this comment.
Reviewer Checklist
- I have verified the author checklist is complete (all boxes are checked off).
- I verified the correct issue is linked in the
### Fixed Issuessection above - I verified testing steps are clear and they cover the changes made in this PR
- I verified the steps for local testing are in the
Testssection - I verified the steps for Staging and/or Production testing are in the
QA stepssection - I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
- I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
- I verified the steps for local testing are in the
- I checked that screenshots or videos are included for tests on all platforms
- I included screenshots or videos for tests on all platforms
- I verified tests pass on all platforms & I tested again on:
- Android: Native
- Android: mWeb Chrome
- iOS: Native
- iOS: mWeb Safari
- MacOS: Chrome / Safari
- MacOS: Desktop
- If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
- I verified proper code patterns were followed (see Reviewing the code)
- I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e.
toggleReportand notonIconClick). - I verified that the left part of a conditional rendering a React component is a boolean and NOT a string, e.g.
myBool && <MyComponent />. - I verified that comments were added to code that is not self explanatory
- I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
- I verified any copy / text shown in the product is localized by adding it to
src/languages/*files and using the translation method - I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
- I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is approved by marketing by adding the
Waiting for Copylabel for a copy review on the original GH to get the correct copy. - I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
- I verified the JSDocs style guidelines (in
STYLE.md) were followed
- I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e.
- If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
- I verified that this PR follows the guidelines as stated in the Review Guidelines
- I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like
Avatar, I verified the components usingAvatarhave been tested & I retested again) - I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
- I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
- If a new component is created I verified that:
- A similar component doesn't exist in the codebase
- All props are defined accurately and each prop has a
/** comment above it */ - The file is named correctly
- The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
- The only data being stored in the state is data necessary for rendering and nothing else
- For Class Components, any internal methods passed to components event handlers are bound to
thisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor) - Any internal methods bound to
thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick) - All JSX used for rendering exists in the render method
- The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
- If any new file was added I verified that:
- The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
- If a new CSS style is added I verified that:
- A similar style doesn't already exist
- The style can't be created with an existing StyleUtils function (i.e.
StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
- If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
- If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like
Avataris modified, I verified thatAvataris working as expected in all cases) - If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
- If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
- If the PR modifies the form input styles:
- I verified that all the inputs inside a form are aligned with each other.
- I added
Designlabel so the design team can review the changes.
- If a new page is added, I verified it's using the
ScrollViewcomponent to make it scrollable when more elements are added to the page. - If the
mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps. - I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.
🎀 👀 🎀 C+ reviewed
|
Backend PR was merged https://github.com/Expensify/Auth/pull/15989 |
| /** Holds the transaction data entry from Onyx */ | ||
| transaction: OnyxEntry<Transaction>; | ||
|
|
||
| /** The original amount value on the transaction. This is used to deduce who is the sender and who is the receiver of the money request |
There was a problem hiding this comment.
I do not like the word original in this context as technically we have the modified amount, that is the changed/edited amount and amount is the original initially set amount so I think this could be slightly confusing to some
| /** The original amount value on the transaction. This is used to deduce who is the sender and who is the receiver of the money request | |
| /** The amount of the transaction saved in the database. This is used to deduce who is the sender and who is the receiver of the money request |
There was a problem hiding this comment.
Sounds good. We a few different versions of the amount so the nomenclature is tricky.
For split, if I split 10usd with you 5/5, then there exists both a transaction for (+|-)500 and the transaction for full 1000
|
✋ 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/mountiny in version: 9.1.73-0 🚀
|
|
🚀 Deployed to production by https://github.com/puneetlath in version: 9.1.73-0 🚀
|



This PR fixes messy logic around displaying
from(sender) andto(receiver) for IOU transaction previews.Explanation of Change
fromandtofields based on the sign (positive/negative) of the transaction amount - this approach was consulted with @mountiny and it's the best we have in the case of opening chat report and looking at a previewgetIOUDatafunction, which I renamed togetIOUPayerAndReceiverto make it more clear - this operation happens only for IOU reportsMath.absover it, so it was always positive, and we always got the same order offromandtoso now I'm passing the original amount without abs to make this workFixed Issues
$ #62783
PROPOSAL:
Tests
Follow steps from original bug.
Offline tests
QA Steps
Follow steps from original bug.
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))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
rec-transaction-preview-andr.mp4
Android: mWeb Chrome
iOS: Native
transaction-preview-ios.mp4
iOS: mWeb Safari
MacOS: Chrome / Safari
transaction-preview-web.mp4
MacOS: Desktop