-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Add an action method for creating a distance request #24385
Conversation
@neil-marcellini Would you mind pulling this branch and seeing if there are any regressions when requesting money? I tried this over and over again in my environment and I ran into so many server errors that I couldn't get this tested. I'm thinking I need to rebuild my VM completely to try and get it tested. |
Nevermind, it looks like rebuilding my VM and starting with a fresh database works 👍 |
@robertKozik @ One of you needs to 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] |
This is ready for review, but I am having a difficult time getting anything to run on Android, so that is where my testing is being held-up. @robertKozik maybe you are able to have better luck testing this on Android than me! |
I finally got Android running and finished testing this. |
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.
Looking good and tests well. I realized we need to make one modification regarding the optimistic transaction.
src/libs/actions/IOU.js
Outdated
@@ -364,7 +377,7 @@ function requestMoney(report, amount, currency, payeeEmail, payeeAccountID, part | |||
receiptObject.source = receipt.source; | |||
receiptObject.state = CONST.IOU.RECEIPT_STATE.SCANREADY; | |||
} | |||
const optimisticTransaction = TransactionUtils.buildOptimisticTransaction(amount, currency, iouReport.reportID, comment, '', '', undefined, receiptObject); | |||
const transaction = TransactionUtils.buildOptimisticTransaction(amount, currency, iouReport.reportID, comment, '', '', undefined, receiptObject); |
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.
For distance requests we create the transaction optimistically as soon as the flow starts, so we need to get that transaction and merge it with the other optimistic transaction data built here.
App/src/pages/iou/DistanceRequestPage.js
Line 29 in 8263331
IOU.createEmptyTransaction(); |
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.
OK, it looks like createEmptyTransaction()
is a method that generates a random transactionID (I think maybe it is a poorly named method). In order to use that transactionID, I have modified createDistanceRequest()
to accept an existing transaction ID. This ID is then used when creating the optimistic transaction in this code instead of generating a new random ID.
I think that should be all that is needed for when someone hooks up to the createDistanceRequest()
method, but please double-check my assumptions.
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 can build the optimistic transaction with the same ID, but then we still need to merge it with the transaction that already exists in Onyx. The existing transaction will have waypoints set on it, and maybe some other data that I don't think we want to lose.
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.
Looking better, but as I mentioned in an earlier thread I think we should merge the optimistic transaction with the one that is currently stored in Onyx.
src/libs/actions/IOU.js
Outdated
@@ -101,7 +101,7 @@ function buildOnyxDataForMoneyRequest( | |||
const optimisticData = [ | |||
{ | |||
// Use SET for new reports because it doesn't exist yet, is faster and we need the data to be available when we navigate to the chat page | |||
onyxMethod: isNewChatReport ? Onyx.METHOD.SET : Onyx.METHOD.MERGE, | |||
onyxMethod: 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.
Why are we removing this condition?
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.
These are being changed because:
- Set and merge shouldn't be mixed. It will lead to undefined behavior of the order in which subscribers are updated (ie. you end up seeing a little flash of incorrect data as amounts go from $0 to whatever was set in the request).
- Using
set
just because "it's faster" is not a reason to use set
I checked with @luacmartins who originally made the change and we agreed it was OK to use merge for everything for now.
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.
Tests well!
@aldo-expensify 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] |
I was not able to reproduce this one. 2023-08-17_09-06-54.mp4 |
Oh wait, you said from "a new user". I was able to reproduce it now after I caught that. Looking into it. |
It's not related to this PR but a regression from a another PR merged yesterday. |
OK, I've reverted a lot of the
|
I can re-review in an hour or two if that is fine. |
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.
Looking good. Tested again both in offline and online mode. Did not see anything broken!
@francoisl 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] |
✋ 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/neil-marcellini in version: 1.3.56-0 🚀
|
🚀 Deployed to production by https://github.com/roryabraham in version: 1.3.56-24 🚀
|
0, | ||
'USD', | ||
payeeAccountID, | ||
payeeEmail, | ||
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.
This caused #26518. We shouldn't have passed in static values like 0
in here if optimistic creation of these requests was supported.
Details
This PR adds a new method to the IOU action file for creating a distance request. Since the majority of the logic was shared with
requestMoney()
, much of the code needed to be DRYed and moved to another method.Fixed Issues
$ #22711
Tests
Note: This logic is not connected to anything at the moment so the only test to do is to ensure that there are no regressions when requesting money.
Offline tests
None
QA Steps
Same as tests
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting 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
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)ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Web
Mobile Web - Chrome
Mobile Web - Safari
Desktop
iOS
Android