-
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
fix: unify TBD-related logic for Distance requests #34135
fix: unify TBD-related logic for Distance requests #34135
Conversation
@parasharrajat 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] |
# Conflicts: # src/components/ReportActionItem/MoneyRequestPreview.js
# Conflicts: # src/components/ReportActionItem/ReportPreview.js # src/libs/ReportUtils.ts
@paultsimura I'm going to convert this to a draft so we can tell when it's ready. |
# Conflicts: # src/components/ReportActionItem/MoneyRequestPreview.js
@@ -266,8 +266,8 @@ function getDescription(transaction: OnyxEntry<Transaction>): string { | |||
/** | |||
* Return the amount field from the transaction, return the modifiedAmount if present. | |||
*/ | |||
function getAmount(transaction: OnyxEntry<Transaction>, isFromExpenseReport: boolean): number { | |||
// IOU requests cannot have negative values but they can be stored as negative values, let's return absolute value | |||
function getAmount(transaction: OnyxEntry<Transaction>, isFromExpenseReport = false): number { |
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.
There are a bunch of places where this second parameter is not provided. So I've set it to default false
to avoid "Wrong params count" errors.
@paultsimura In case you didn't see, there's more conflicts 🥲 |
# Conflicts: # src/libs/ReportUtils.ts # src/libs/actions/IOU.ts
Thank you for the ping, resolved again ✔️ |
const isDistanceRequestWithoutRoute = isDistanceRequest && !hasRoute; | ||
const formattedAmount = isDistanceRequestWithoutRoute | ||
? translate('common.tbd') | ||
const isDistanceRequestWithPendingRoute = isDistanceRequest && (!hasRoute || !rate); |
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 isn't this using isFetchingWaypointsFromServer()
?
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 isFetchingWaypointsFromServer
depends on this variable, not vice versa:
App/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js
Lines 477 to 479 in e63553c
if (isDistanceRequestWithPendingRoute) { | |
IOU.setMoneyRequestPendingFields(transaction.transactionID, {waypoints: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD}); | |
} |
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 feel like that's kind of an anti pattern. I think we should only call actions based directly on user action, not based on data changing. Do you agree Tim?
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.
But we already do call these actions in multiple places when landing on different steps of the IOU creation. Since in all these places we update the draft transaction, it looks more like a way to transfer the state between the IOU creation steps, and not an actual data modification.
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.
Ah, I think you're both right. @paultsimura you're correct that this is more akin to storing the form state between steps. @neil-marcellini I think you might be onto something about this looking like an anti-pattern.
What do you think about this?
- Instead of calling
IOU.setMoneyRequestPendingFields(transaction.transactionID, {waypoints: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD});
on this page, set that data on the previous page when the user submits the form. I think it could be part of the data that gets set here:Transaction.updateWaypoints(transactionID, newWaypoints, true).then(() => {
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 issue here is the following scenario:
The user completes the first steps up until the confirmation step while being offline. Then, on the confirmation step, they come back online. Here, the map should get fetched, and we no longer should have the waypoints pending (even though when we landed on this page, the map was still pending).
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, that darn offline flow gets confusing! Thanks for pointing that out. It's probably OK then, but I would ask that you also put that context into a code comment where it happens.
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.
Got you, thanks for taking your time on this. Updated ✔️
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, on the confirmation step, they come back online. Here, the map should get fetched, and we no longer should have the waypoints pending
Thank you for explaining. I think that flow makes sense, but how does that relate to this condition? If we are offline and set the waypoints pending when they are updated (as Tim suggested), then when the user is navigated to this page the pending fields will show correctly. Once they go back online I would think that the GetRoute response should clear the pending fields for the waypoints (and or the route), and then all data on the confirmation page would no longer show as pending. Does that make sense?
I'm going to leave this as a NAB. We could fix it in a follow up if needed.
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.
Probably yes, but I'm not sure where to attach the workspace rate being still loaded in this case. That being said, I would really appreciate it if we could merge this PR as-is if it's an NAB. It's my longest one so far 🙂
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 it's pretty much good to go, but Tim did point out something a bit weird so I'll wait to approve until we get that settled.
const isDistanceRequestWithoutRoute = isDistanceRequest && !hasRoute; | ||
const formattedAmount = isDistanceRequestWithoutRoute | ||
? translate('common.tbd') | ||
const isDistanceRequestWithPendingRoute = isDistanceRequest && (!hasRoute || !rate); |
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 feel like that's kind of an anti pattern. I think we should only call actions based directly on user action, not based on data changing. Do you agree Tim?
# Conflicts: # src/libs/ReportUtils.ts
@tgolen @neil-marcellini please re-review before we have new conflicts 🙂 🙏 |
Can you merge main to clear up the failing reassure performance tests? |
@amyevans done ✔️ |
✋ 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.4.39-0 🚀
|
🚀 Deployed to production by https://github.com/Beamanator in version: 1.4.39-8 🚀
|
Details
Fixed Issues
$ #33362
PROPOSAL: #33362 (comment)
Large Slack discussion: https://expensify.slack.com/archives/C01GTK53T8Q/p1705425683928599
Tests
Same as QA
Offline tests
Same as QA
QA Steps
amount
is blankdistance
shows "Route pending..."Route pending...
Route pending...
$0
Route pending
Route pending
Route pending
and the amount is not shownPR 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)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label so the design team can review the changes.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-compressed.mp4
Android: mWeb Chrome
chrome-compressed.mp4
iOS: Native
Simulator.Screen.Recording.-.iPhone.15.Pro.-.2024-01-09.at.15.02.49-compressed.mp4
iOS: mWeb Safari
Simulator.Screen.Recording.-.iPhone.15.Pro.-.2024-01-09.at.14.54.34-compressed.mp4
MacOS: Chrome / Safari
Screen.Recording.2024-01-20.at.20.28.56-compressed.mp4
MacOS: Desktop
Screen.Recording.2024-01-09.at.15.05.45-compressed.mp4