-
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: Handle distance unit update when sharing #54048
fix: Handle distance unit update when sharing #54048
Conversation
@Pujan92 we probably should hold this one because the original PR was reverted 😿 |
Oh yes, I just got to know about the revert. |
# Conflicts: # src/libs/actions/IOU.ts
@paultsimura Is this ready for review now? |
I'll merge |
# Conflicts: # tests/unit/TransactionUtilsTest.ts
Ready for review @Pujan92 |
Bump for review @Pujan92 |
Reviewer Checklist
Screenshots/VideosAndroid: NativeAndroid: mWeb ChromeiOS: NativeiOS: mWeb SafariMacOS: Chrome / SafariScreen.Recording.2025-02-05.at.14.16.39.movMacOS: Desktop |
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.
Looks good overall, @neil-marcellini do you want to give this a review since it is a follow up to #51517 (review)?
@@ -992,7 +992,11 @@ function hasWarningTypeViolation(transactionID: string | undefined, transactionV | |||
/** | |||
* Calculates tax amount from the given expense amount and tax percentage | |||
*/ | |||
function calculateTaxAmount(percentage: string, amount: number, currency: string) { | |||
function calculateTaxAmount(percentage: string | undefined, amount: number, currency: string) { |
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 is percentage optional?
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.
This is a byproduct of the Lint fix. We used to pass an empty string before:
App/src/pages/iou/request/step/IOURequestStepDistanceRate.tsx
Lines 90 to 91 in 5d3622d
const taxPercentage = TransactionUtils.getTaxValue(policy, transaction, taxRateExternalID) ?? ''; | |
taxAmount = CurrencyUtils.convertToBackendAmount(TransactionUtils.calculateTaxAmount(taxPercentage, taxableAmount, rates[customUnitRateID].currency ?? CONST.CURRENCY.USD)); |
To make it more clear, I've changed ''
to undefined
, and therefore had to make the percentage
param string | undefined
.
If you prefer, I can revert the param change and try to modify the logic where I'm calling this function instead.
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, thanks for clarifying. Yeah, I think it's a bit strange to call calculateTaxAmount
with no percentage. It would be good to modify the place where the function is called but it's beyond the scope of this PR so I think it's fine as it is.
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.
Overall looks good, but I have one question.
src/libs/actions/IOU.ts
Outdated
comment: { | ||
customUnit: { | ||
customUnitRateID, | ||
defaultP2PRate: null, |
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 should only clear this if there's a policy right?
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've checked the code - this function is called in only 1 place - when a user manually changes the distance rate:
App/src/pages/iou/request/step/IOURequestStepDistanceRate.tsx
Lines 96 to 102 in ad708d7
if (currentRateID !== customUnitRateID) { | |
setMoneyRequestDistanceRate(transactionID, customUnitRateID, policy, shouldUseTransactionDraft(action)); | |
if (isEditing && transaction?.transactionID) { | |
updateMoneyRequestDistanceRate(transaction.transactionID, reportID, customUnitRateID, policy, policyTags, policyCategories, taxAmount, taxRateExternalID); | |
} | |
} |
This action is not accessible for non-policy requests, as we use only default P2P rate for 1:1 requests.
But I will add a policy-only condition 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.
Great thanks. Yeah even though it's not a problem in the current flow it's always good to have the check so someone doesn't add a call and accidentally create a bug.
🚀 Deployed to staging by https://github.com/neil-marcellini in version: 9.0.96-0 🚀
|
🚀 Deployed to production by https://github.com/Julesssss in version: 9.0.96-1 🚀
|
Explanation of Change
Fix the case when the workspace distance unit differs from the tracked expense's when sharing from Self DM.
Fixed Issues
$ #53988
PROPOSAL: #53988 (comment)
Tests
Same as QA
Offline tests
Same as QA
QA Steps
Precondition:
Test:
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)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.webm
Android: mWeb Chrome
chrome.webm
iOS: Native
Simulator.Screen.Recording.-.iPhone.15.Pro.-.2024-12-12.at.18.17.50.mp4
iOS: mWeb Safari
Simulator.Screen.Recording.-.iPhone.15.Pro.-.2024-12-12.at.18.16.29.mp4
MacOS: Chrome / Safari
Screen.Recording.2024-12-12.at.18.02.32.mov
MacOS: Desktop
Screen.Recording.2024-12-12.at.18.08.22.mov