-
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: show disabled distance rate if it is selected in IOU request #47850
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] |
Will review this by tomorrow. |
@@ -65,6 +64,8 @@ function IOURequestStepDistanceRate({ | |||
|
|||
const currentRateID = TransactionUtils.getRateID(transaction) ?? '-1'; | |||
|
|||
const rates = DistanceRequestUtils.getMileageRates(policy, false, currentRateID); |
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 don't see the change to remove the Onyx keys. Is it already removed in another PR/refactor?
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.
Yes, it is removed in #46859
Code change is okay. Will work on the checklist. |
Reviewer Checklist
Screenshots/Videos |
I also tested a scenario where we have multiple disabled rates:
|
quick bump @iwiznia |
@@ -45,7 +46,7 @@ function getMileageRates(policy: OnyxInputOrEntry<Policy>, includeDisabledRates | |||
} | |||
|
|||
Object.entries(distanceUnit.rates).forEach(([rateID, rate]) => { | |||
if (!includeDisabledRates && rate.enabled === false) { | |||
if (!includeDisabledRates && rate.enabled === false && (!selectedRateID || rateID !== selectedRateID)) { |
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.
!selectedRateID
would fail if we have a rateID that's "0"
no?
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 selectedRateID = "0"
this condition !selectedRateID
will be false (which is expected), no?
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.
No, "0"
would be the ID, which means it has an ID
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.
No, "0" would be the ID, which means it has an ID
Sorry, I don't quite follow what you mean by '0' being the ID. Could you clarify that for me?
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 I create a rate whose ID is the string "0"
then select it, this would not work because !"0"
is false but that's wrong because we indeed passed an ID, so we should've compared selectedRateID
with rateID
but we did not
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.
so we should've compared selectedRateID with rateID but we did not
- No. I think with the current condition:
if (!includeDisabledRates && rate.enabled === false && (!selectedRateID || rateID !== selectedRateID)) {
we still compare selectedRateID with rateID via rateID !== selectedRateID
.
CMIIWW. Thanks
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, you are right! I was confusing the behavior with PHP where "0"
is falsy
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
Details
Fixed Issues
$ #46884
PROPOSAL: #46884 (comment)
Tests
Precondition:
Workspace has some distance rates.
2. Go to NewDot app
3. Go to workspace chat.
4. Submit a distance expense with Distance rate A.
5. Go to workspace settings > Distance rates.
6. Disable Distance rate A used in Step 3.
7. Go back to transaction thread of the distance expense.
8. Click Rate.
Verify that: The disabled rate will appear selected in the Rate list but grayed out (like Category and Tag when selected and disabled afterward).
Offline tests
QA Steps
Precondition:
Workspace has some distance rates.
2. Go to NewDot app
3. Go to workspace chat.
4. Submit a distance expense with Distance rate A.
5. Go to workspace settings > Distance rates.
6. Disable Distance rate A used in Step 3.
7. Go back to transaction thread of the distance expense.
8. Click Rate.
Verify that: The disabled rate will appear selected in the Rate list but grayed out (like Category and Tag when selected and disabled afterward).
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodSTYLE.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 and/or tagged@Expensify/design
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: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop