-
Notifications
You must be signed in to change notification settings - Fork 3.4k
fix: allow creating Distance request from expense reports #30881
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
fix: allow creating Distance request from expense reports #30881
Conversation
|
@thesahindia 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] |
Reviewer Checklist
Screenshots/VideosAndroid: NativeScreen.Recording.2023-11-07.at.2.15.54.PM.movAndroid: mWeb ChromeScreen.Recording.2023-11-07.at.2.13.00.PM.moviOS: NativeScreen.Recording.2023-11-07.at.2.25.09.PM.moviOS: mWeb SafariScreen.Recording.2023-11-07.at.2.20.11.PM.movMacOS: Chrome / SafariScreen.Recording.2023-11-06.at.10.57.24.PM.movMacOS: DesktopScreen.Recording.2023-11-07.at.2.26.26.PM.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!
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.
Excellent thank you
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
| function createDistanceRequest(report, participant, comment, created, transactionID, category, tag, amount, currency, merchant, billable) { | ||
| // If the report is an iou or expense report, we should get the linked chat report to be passed to the getMoneyRequestInformation function | ||
| const isMoneyRequestReport = ReportUtils.isMoneyRequestReport(report); | ||
| const currentChatReport = isMoneyRequestReport ? ReportUtils.getReport(report.chatReportID) : report; |
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 this is an incorrect change. Why not pass the proper report object to createDistanceRequest() in the first place?
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 use the same approach when creating a regular money request:
Lines 847 to 851 in 1dc4593
| // If the report is iou or expense report, we should get the linked chat report to be passed to the getMoneyRequestInformation function | |
| const isMoneyRequestReport = ReportUtils.isMoneyRequestReport(report); | |
| const currentChatReport = isMoneyRequestReport ? ReportUtils.getReport(report.chatReportID) : report; | |
| const {payerAccountID, payerEmail, iouReport, chatReport, transaction, iouAction, createdChatReportActionID, createdIOUReportActionID, reportPreviewAction, onyxData} = | |
| getMoneyRequestInformation(currentChatReport, participant, comment, amount, currency, created, merchant, payeeAccountID, payeeEmail, receipt, undefined, category, tag, billable); |
What exactly do you mean by a "proper report object" here: is it the one we are fetching as currentChatReport? If so, we'll still need to tell apart a request created from a chat and the one created from an expense report so that we can navigate the user properly. Would you have any suggestions for it?
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 because we do it somewhere else, doesn't mean it's right. It just means that you get to fix it in two places 🎉
What I am saying is that the logic that you added inside the method should have been done outside of the method, and then the proper "chat report" is what is passed to the method in the report param.
If you need something else for the navigation, then I would consider:
- Moving navigation out of this method (I also dislike this method is doing navigation, it is an anti-pattern of separating concerns)
- Using a different param to control the navigation specifically
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.
Makes sense. Since this PR is already merged, would you want me to create a cleanup one?
|
🚀 Deployed to production by https://github.com/puneetlath in version: 1.3.97-7 🚀
|
|
🚀 Deployed to staging by https://github.com/neil-marcellini in version: 1.3.98-0 🚀
|
|
🚀 Deployed to production by https://github.com/roryabraham in version: 1.3.98-5 🚀
|
Details
Allow creating Distance request from expense reports
Fixed Issues
$ #30407
PROPOSAL: #30407 (comment)
Tests
Same as QA.
Offline tests
Same as QA.
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodWaiting for Copylabel for a copy review on the original GH to get the correct copy.STYLE.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)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
Android-compressed.mp4
Android: mWeb Chrome
chrome-compressed.mp4
iOS: Native
iOS.mov
iOS: mWeb Safari
safari.mp4
MacOS: Chrome / Safari
web-compressed.mp4
MacOS: Desktop
Desktop-compressed.mp4