-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Refactor payIOU
#12739
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor payIOU
#12739
Conversation
payIOU
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@youssef-lr I think we should in a big part just reused the requestMoney here and then add what we need for this specific command.
Essentially the good thing about Send money request is that we dont have to update any of the totals etc since that is untouched, we will add a new report actions, that is requested and paid.
mountiny
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@youssef-lr on a good track, just couple of comments
Co-authored-by: Vit Horacek <36083550+mountiny@users.noreply.github.com>
mountiny
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@youssef-lr Love the refactor, lets add videos and make this ready for a review as well as the Web-PR.
src/libs/actions/IOU.js
Outdated
| } = getPayMoneyRequestParams( | ||
| chatReport, iouReport, recipient, CONST.IOU.PAYMENT_TYPE.ELSEWHERE, | ||
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| } = getPayMoneyRequestParams( | |
| chatReport, iouReport, recipient, CONST.IOU.PAYMENT_TYPE.ELSEWHERE, | |
| ); | |
| } = getPayMoneyRequestParams(chatReport, iouReport, recipient, CONST.IOU.PAYMENT_TYPE.ELSEWHERE); |
|
@luacmartins for the IOU Preview bug after an error, it's because of the check here which decides if we should show it or it. When we pay a cancelled request, the last IOU action (which is of type 'cancel') satisfies that check and we end up showing the preview. I fixed it in this commit by adding another check. Let me know what you think! Screen.Recording.2022-12-08.at.03.55.18.mov |
| const shouldShowIOUPreview = ( | ||
| props.isMostRecentIOUReportAction | ||
| && Boolean(props.action.originalMessage.IOUReportID) | ||
| && props.chatReport.hasOutstandingIOU) || props.action.originalMessage.type === 'pay'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think props.chatReport.hasOutstandingIOU || props.action.originalMessage.type === 'pay' alone might be enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@youssef-lr That will make the IOUPreview shown on every IOU report.

We should keep props.isMostRecentIOUReportAction to show IOUPreview for recent IOUReport.

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think props.chatReport.hasOutstandingIOU || props.action.originalMessage.type === 'pay' alone might be enough.
this wont be enough will it, you can send money no matter if you have existing pay request there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
Are we ready for another round? |
|
@mollfpr Correct, but there's one bug/improvement I can't figure out yet. |
| }, | ||
| }, | ||
| { | ||
| onyxMethod: CONST.ONYX.METHOD.MERGE, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@youssef-lr same here, we have paid this up and we included all the data about the iou report in here so we can use set can we not?
| onyxMethod: CONST.ONYX.METHOD.MERGE, | |
| onyxMethod: CONST.ONYX.METHOD.SET, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that we should use merge if the IOUReport is already stored in Onyx. The difference between this and sendMoney is that sendMoney creates an IOUReport that doesn't yet exist in Onyx.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, here we already have an iouReport that we're settling up.
Co-authored-by: Vit Horacek <36083550+mountiny@users.noreply.github.com>
|
This is ready for another round! |
luacmartins
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM and tests well! Awesome job @youssef-lr!
mountiny
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@youssef-lr great job ❤️
Reviewer Checklist
Screenshots/VideosWebMobile Web - ChromeMobile Web - SafariDesktop12739.Desktop.SendMoney.Offline.mov12739.Desktop.SendMoney.Online.mov12739.Desktop.SendMoney.Error.mov12739.Desktop.RequestMoney.Online.mov12739.Desktop.RequestMoney.Error.mov12739.Desktop.RequestMoney.Offline.moviOS12739.iOS.SendMoney.Offline.mov12739.iOS.SendMoney.Online.mov12739.iOS.SendMoney.Error.mov12739.iOS.RequestMoney.Offline.mov12739.iOS.RequestMoney.Online.movAndroid12739.Android.SendMoney.Offline.mov12739.Android.SendMoney.Online.mov12739.Android.SendMoney.Error.mov12739.Android.RequestMoney.Offline.mov12739.Android.RequestMoney.Online.mov12739.Android.RequestMoney.Error.mov |
mollfpr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM tests well 👍
|
Cool, we got the approvals. Let's merge this baby! |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
@laurenreidexpensify could you please pay @mollfpr for their review on this PR (once the regression period is over)? |
|
This has been deployed to staging |
|
🚀 Deployed to production by @chiragsalian in version: 1.2.38-6 🚀
|
|
@mollfpr Upwork job here https://www.upwork.com/jobs/~01166169da982f6883 payment will be on 20 Dec |
|
Accepted, thanks @laurenreidexpensify |
|
Paid 🎉 |
| const successData = [ | ||
| { | ||
| onyxMethod: CONST.ONYX.METHOD.MERGE, | ||
| key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${chatReport.reportID}`, | ||
| value: { | ||
| [optimisticIOUReportAction.sequenceNumber]: { | ||
| pendingAction: null, | ||
| }, | ||
| }, | ||
| }, | ||
| ]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a note here that since we didn't clear the iouReportID in the successData here, it caused this: #16105
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, good find
| case CONST.IOU.PAYMENT_TYPE.PAYPAL_ME: | ||
| paymentMethodMessage = 'using PayPal.me'; | ||
| break; | ||
| default: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, we missed a case CONST.IOU.PAYMENT_TYPE.VBBA causing a bug #21535
| value: { | ||
| ...chatReport, | ||
| lastVisitedTimestamp: Date.now(), | ||
| lastActionCreated: optimisticIOUReportAction.created, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've eventually moved the setting of lastActionCreated from chatReport to iouReport.
Context: #54401
Details
Fixed Issues
$ https://github.com/Expensify/Expensify/issues/213712
Tests & QA
1. SendMoney
Offline
+, selectSend MoneyI'll settle up elsewhereoption in the settlement button dropdown, if you have more options (otherwise you can only see this option)Sent $X for <comment>+in the chat report.Send MoneySent $X for <comment>comment left and IOU preview with the correct amount+again and chooseSend MoneyI'll settle up elsewhereOnline
+again,Send Moneyand choose either User A or User CI'll settle up elsewhereoption.Error
+button and selectSend MoneyI'll settle elsewhere2. PayMoneyRequest
Offline
Pre-requisites:
PaybuttonPaybuttonI'll settle up elsewhereoption in the dropdown and click the settlement buttonSettled up elsewheremessage displays immediatelyYou paid <name of the receiver>and the preview is greyed outXto close the modal and navigate away to a different chat and back againOnline
Payin the IOU Details page, chooseI'll settle up elsewhereoption in the dropdown and click the settlement buttonYou paid <name of the receiver>and is not greyed out.Error
Payin the IOU PreviewCancelon the $10 requestI'll settle up elsewherebutton in the IOU details modal to pay itXto dismiss the error messagePR Author Checklist
### Fixed Issuessection aboveTestssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*filesSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)/** comment above it */thisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)Avataris modified, I verified thatAvataris working as expected in all cases)PR Reviewer Checklist
The reviewer will copy/paste it into a new comment and complete it after the author checklist is completed
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick).src/languages/*filesWaiting for Copylabel for a copy review on the original GH to get the correct copy.STYLE.md) were followedAvatar, I verified the components usingAvatarhave been tested & I retested again)/** comment above it */thisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)Avataris modified, I verified thatAvataris working as expected in all cases)Screenshots
Web
Offline - SendMoney
https://user-images.githubusercontent.com/9680864/204683072-6bde8506-963a-44fd-af41-585d907f230c.mov
Online - SendMoney
https://user-images.githubusercontent.com/9680864/204683025-253dbb7d-4a28-4ae5-8172-dc16ec40cc43.mov
Error - SendMoney
Error.mov
Error 2 - SendMoney
send.money.-.error.mov
PayMoneyRequest
PayMoneyRequest.mov
Mobile Web - Chrome
Mobile Web - Safari
Desktop
iOS
Android