-
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
fix: IOU - "TBD" is missing in the IOU details of the "Amount" field in offline mode #29892
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. |
@@ -123,6 +123,8 @@ function ReportPreview(props) { | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@@ -123,6 +123,8 @@ function ReportPreview(props) { | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we still retain two separate calls, why not use ReportUtils.hasOnlyDistanceRequestTransactions
?
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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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);
@@ -1539,14 +1550,25 @@ function canEditReportAction(reportAction) { | |||
/** | |||
* 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we sure we're getting a string here? I thought transactions is an object?
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'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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am also not 100% sure on this one.
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets stick with the current solution
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.
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
TBD
total amount
is set toTBD
report name
, the amount is displayed asTBD
transaction report name
, the amount is displayed asTBD
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
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