-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
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.
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
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 <[email protected]>
This is ready for another round! |
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!
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 |
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
Details
Fixed Issues
$ https://github.com/Expensify/Expensify/issues/213712
Tests & QA
1. SendMoney
Offline
+
, selectSend Money
I'll settle up elsewhere
option 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 Money
Sent $X for <comment>
comment left and IOU preview with the correct amount+
again and chooseSend Money
I'll settle up elsewhere
Online
+
again,Send Money
and choose either User A or User CI'll settle up elsewhere
option.Error
+
button and selectSend Money
I'll settle elsewhere
2. PayMoneyRequest
Offline
Pre-requisites:
Pay
buttonPay
buttonI'll settle up elsewhere
option in the dropdown and click the settlement buttonSettled up elsewhere
message displays immediatelyYou paid <name of the receiver>
and the preview is greyed outX
to close the modal and navigate away to a different chat and back againOnline
Pay
in the IOU Details page, chooseI'll settle up elsewhere
option in the dropdown and click the settlement buttonYou paid <name of the receiver>
and is not greyed out.Error
Pay
in the IOU PreviewCancel
on the $10 requestI'll settle up elsewhere
button in the IOU details modal to pay itX
to dismiss the error messagePR Author Checklist
### Fixed Issues
section aboveTests
sectionQA steps
sectiontoggleReport
and notonIconClick
)src/languages/*
filesSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG
)Avatar
is modified, I verified thatAvatar
is 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 Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
).src/languages/*
filesWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
have been tested & I retested again)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG
)Avatar
is modified, I verified thatAvatar
is 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