fix: IOU - "TBD" is missing in the IOU details of the "Amount" field in offline mode#29892
Conversation
|
@mananjadhav 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] |
|
@mananjadhav a friendly bump on this PR |
|
Will check in a while. |
|
@paultsimura I am reviewing the code, and testing it. Can you please help resolving the merge conflicts? |
# Conflicts: # src/libs/ReportUtils.js
@mananjadhav done, thanks. |
|
Thanks for resolving the conflicts @paultsimura. Currently reviewing this one. |
| const transactionsWithReceipts = ReportUtils.getTransactionsWithReceipts(props.iouReportID); | ||
| const numberOfScanningReceipts = _.filter(transactionsWithReceipts, (transaction) => TransactionUtils.isReceiptBeingScanned(transaction)).length; | ||
| const hasReceipts = transactionsWithReceipts.length > 0; | ||
| const distanceRequestTransactions = ReportUtils.getDistanceRequestTransactions(props.iouReportID); |
There was a problem hiding this comment.
My recommendation could be opinionated, but we're looping through transactions quite a few times.
- getTransactionsWithReceipts
- getDistanceRequestTransactions
Should we be combining these method? Is the list going to be too long to delay the loop?
There was a problem hiding this comment.
The list shouldn't generally exceed 5-10 reports because once the IOU report is settled, it's closed and a new one will be created.
To my mind, creating a separate method that combines both checks is not worth the hustle: it's either creating a new function in ReportUtils that will be used in this only place or fetching all the report's transactions here and placing these custom calculations inside the ReportPreview, which will complicate the already quite cluttered code.
What do you think?
There was a problem hiding this comment.
That's true for users, but admins will likely see 10's of IOUs towards the end of the month. Though we probably don't need to improve this until it becomes a problem.
| const transactionsWithReceipts = ReportUtils.getTransactionsWithReceipts(props.iouReportID); | ||
| const numberOfScanningReceipts = _.filter(transactionsWithReceipts, (transaction) => TransactionUtils.isReceiptBeingScanned(transaction)).length; | ||
| const hasReceipts = transactionsWithReceipts.length > 0; | ||
| const distanceRequestTransactions = ReportUtils.getDistanceRequestTransactions(props.iouReportID); |
There was a problem hiding this comment.
If we still retain two separate calls, why not use ReportUtils.hasOnlyDistanceRequestTransactions ?
There was a problem hiding this comment.
I was a bit concerned about checking this value against the report transactions (which is done inside ReportUtils.hasOnlyDistanceRequestTransactions), while all the rest here are compared with numberOfRequests, which is taken from reportPreviewAction.childMoneyRequestCount.
But looks like we are safe to use the ReportUtils.hasOnlyDistanceRequestTransactions here indeed.
src/libs/ReportUtils.js
Outdated
| * @param {string|null} iouReportID | ||
| * @returns {[Object]} | ||
| */ | ||
| function getDistanceRequestTransactions(iouReportID) { |
There was a problem hiding this comment.
I think we don't need this method as we are only calling it once and that too only to check if we have only distance requests here:
const distanceRequestTransactions = ReportUtils.getDistanceRequestTransactions(props.iouReportID);
const hasOnlyDistanceRequests = numberOfRequests === _.size(distanceRequestTransactions);
| * Gets all transactions on an IOU report with a receipt | ||
| * | ||
| * @param {Object|null} iouReportID | ||
| * @param {string|null} iouReportID |
There was a problem hiding this comment.
Are we sure we're getting a string here? I thought transactions is an object?
There was a problem hiding this comment.
We're not getting – it's the input parameter of the function, iouReportID.
| */ | ||
| function hasOnlyDistanceRequestTransactions(iouReportID) { | ||
| const allTransactions = TransactionUtils.getAllReportTransactions(iouReportID); | ||
| return _.all(allTransactions, (transaction) => TransactionUtils.isDistanceRequest(transaction)); |
There was a problem hiding this comment.
I can't find the link or doc, but I thought we're going to prioritize using the built-in methods over lodash if they exist. We could use
return allTransactions.every(transaction => TransactionUtils.isDistanceRequest(transaction));
@Julesssss Can you confirm this?
There was a problem hiding this comment.
As far as I understand, this is more related to TypeScript, as it's more fail-safe. But if you insist, I can change to .every here
There was a problem hiding this comment.
I am also not 100% sure on this one.
There was a problem hiding this comment.
Then I would like to keep it as is until the file is migrated to TypeScript, just to make it consistent with the rest of the functions
There was a problem hiding this comment.
Lets stick with the current solution
mananjadhav
left a comment
There was a problem hiding this comment.
Raised a comment about unwanted method, and one-two nit comments.
|
Changes look fine, starting with the QA and checklist now. |
|
@paultsimura @Julesssss I am trying to follow the test steps but I can't request money offline. web-offline-distance-request.mov |
There was a known bug in Dev: #30022 It's fixed now after I pulled the latest |
Reviewer Checklist
Screenshots/VideosWebweb-offline-amt-tbd.movMobile Web - Chromemweb-chrome-offline-amt-tbd.movMobile Web - Safarimweb-safari-offline-amt-tbd.movDesktopdesktop-offline-amt-tbd.moviOSios-offline-amt-tbd.movAndroidandroid-offline-amt-tbd.mov |
|
Thanks @paultsimura for addressing the comments. This tests well. @Julesssss All yours. 🎀 👀 🎀 C+ reviewed. |
|
✋ 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/Julesssss in version: 1.3.88-0 🚀
|
|
🚀 Deployed to production by https://github.com/chiragsalian in version: 1.3.88-11 🚀
|
Details
Display the amount of IOU Reports that consist only of "TBD" distance requests as "TBD".
Fixed Issues
$ #29553
PROPOSAL: #29553 (comment)
Tests
Same as QA.
Offline tests
Same as QA.
QA Steps
TBDtotal amountis set toTBDreport name, the amount is displayed asTBDtransaction report name, the amount is displayed asTBDPR 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.mov
Android: mWeb Chrome
chrome.mov
iOS: Native
iOS.mp4
iOS: mWeb Safari
RPReplay_Final1697649389.MP4
MacOS: Chrome / Safari
web.mov
MacOS: Desktop
desktop.mov