-
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
Feat/36985 create new rate field #38543
Feat/36985 create new rate field #38543
Conversation
@getusha done |
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 & tests well
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.
All good to go except one tiny thing which is passing the right iouType to usePermissions for p2p distance on the money request view.
I left a bunch of non blocking comments too. You can address some now if you like, or handle them all in a follow up.
|
||
const currency = policy ? policy.outputCurrency : PolicyUtils.getPersonalPolicy()?.outputCurrency ?? CONST.CURRENCY.USD; | ||
|
||
const mileageRate = TransactionUtils.isCustomUnitRateIDForP2P(transaction) ? DistanceRequestUtils.getRateForP2P(currency) : rates[rateID as 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.
NAB: There's another complication here that we forgot about. Let's handle it in a follow up PR please, since I don't want to delay this one more and add more complexity.
If we're viewing an old request, and the defaultP2P rates have changed since the request was created, then we might display the wrong rate because the rate the request was created with is no longer in the default mapping.
Therefore when viewing a created request we should first try to get the default rate from transaction.comment.customUnit.defaultP2PRate
. It stores the rate value number only.
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.
@neil-marcellini ok I missed this one - will implement this
|
||
return `${formattedDistance} @ ${currencySymbol}${ratePerUnit} / ${singularDistanceUnit}`; | ||
function getRateForP2P(currency: string): RateAndUnit { |
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.
NAB: Noting that this is where we need to handle getting the rate from the transaction defaultP2PRate
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.
@neil-marcellini you mean adding a comment what this function does?
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.
Implementing this
} | ||
|
||
const distance = Number(merchant.split(' ')[0]); | ||
if (!distance) { |
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.
NAB: It would also be a good idea to validate that the merchant has the expected format and return 0 if it does not. The regex we're using on the backend is found in a comment I posted here. Let's do this in a follow up.
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.
@neil-marcellini FYI: I needed to change this regex a bit, /^[0-9.]+ \w+ @ (-|-\()?(\p{Sc}|\p{L}|\w){1,3} ?[0-9.]+\)? \/ \w+$/u
- added an "u" flag to catch unicode and this one: \p{L}
bc the regex didn't work when we had PLN currency - "zł"
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.
Ok great thanks. If you would please provide some examples where it breaks with the old regex, then I can get the backend fixed too so that the regexes match.
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 found that requesting money with a custom rate on a workspace doesn't work. @getusha your test video shows it failing in a different way, so it looks like maybe you skipped this.
It looks like we're not sending the customUnitRateID
param to the backend. After the updates, @getusha would you please also test the case of viewing an expense with a custom rate shortly after signing in?
customRate720.mov
@getusha could you please retest? |
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, it looks like creating with a custom rate is fixed.
Screen.Recording.2024-04-19.at.12.10.31.PM.mov
Also viewing the money request after signing back in works well. All set! We will handle the rest in follow ups.
Screen.Recording.2024-04-19.at.12.11.43.PM.mov
Tim is out today and I want to get this merged for #urgency
✋ 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 production by https://github.com/mountiny in version: 1.4.64-6 🚀
|
function hasRoute(transaction: OnyxEntry<Transaction>): boolean { | ||
return !!transaction?.routes?.route0?.geometry?.coordinates; | ||
function hasRoute(transaction: OnyxEntry<Transaction>, isDistanceRequestType: boolean): boolean { | ||
return !!transaction?.routes?.route0?.geometry?.coordinates || (isDistanceRequestType && !!transaction?.comment?.customUnit?.quantity); |
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.
In saveWaypoint
function, you forgot to clear comment.customUnit.quantity
, which caused #40934
This PR also created issue: which consists of 2 bugs:
Neil acknowledged the oversight in #42284 (comment):
|
const customUnitRateID = TransactionUtils.getRateID(transaction) ?? ''; | ||
|
||
useEffect(() => { | ||
if (customUnitRateID || !canUseP2PDistanceRequests) { |
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 shouldn't have returned early for P2P distance requests, instead we should had checked for canUseP2PDistanceRequests
while assigning rateID
, this caused #45856
Details
Fixed Issues
$ #36985
PROPOSAL: -
Tests
P2P / Splits
+
) > Submit expense** Workspace Requests**
Prerequisites:
+
) > Submit expenseMoney Request View
Sign in/out
Offline tests
n/a
QA Steps
P2P / Splits
+
) > Request money** Workspace Requests**
Prerequisites:
+
) > Request moneyMoney Request View
Sign in/out
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
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)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
Screen.Recording.2024-03-29.at.12.56.06.mp4
Android: mWeb Chrome
iOS: Native
Simulator.Screen.Recording.-.iPhone.15.Pro.-.2024-03-28.at.21.30.34.mov
iOS: mWeb Safari
Simulator.Screen.Recording.-.iPhone.15.Pro.-.2024-03-28.at.21.49.07.mov
MacOS: Chrome / Safari
https://github.com/Expensify/App/assets/28020445/3ac987f8-0e5c-482a-bb0e-23eeab7c8f02
MacOS: Desktop
Screen.Recording.2024-03-28.at.21.54.30.mp4