fix: p2p rate is selected when tracking distance in a workspace#74662
fix: p2p rate is selected when tracking distance in a workspace#74662Beamanator merged 7 commits intoExpensify:mainfrom
Conversation
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
|
@DylanDylann 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] |
|
|
||
| setCustomUnitRateID(transactionID, rateID); | ||
| }, [defaultMileageRate, customUnitRateID, lastSelectedDistanceRates, policy?.id, transactionID, isDistanceRequest]); | ||
| }, [defaultMileageRate, customUnitRateID, lastSelectedDistanceRates, policy?.id, transactionID, isDistanceRequest, isPolicyExpenseChat, isMovingTransactionFromTrackExpense]); |
There was a problem hiding this comment.
❌ PERF-6 (docs)
Passing entire objects (defaultMileageRate, lastSelectedDistanceRates) as dependencies causes the useEffect to re-execute whenever any property changes, even unrelated ones. This hook only uses defaultMileageRate?.customUnitRateID and accesses lastSelectedDistanceRates?.[policy.id].
Suggested fix:
// Extract specific properties before the useEffect
const defaultMileageRateID = defaultMileageRate?.customUnitRateID;
const lastSelectedRateForPolicy = lastSelectedDistanceRates?.[policy?.id ?? ''];
// Then in the useEffect, use these values and update the dependency array:
}, [defaultMileageRateID, customUnitRateID, lastSelectedRateForPolicy, policy?.id, transactionID, isDistanceRequest, isPolicyExpenseChat, isMovingTransactionFromTrackExpense]);| !isPolicyExpenseChat || | ||
| !transactionID || | ||
| !lastSelectedRate || | ||
| isMovingTransactionFromTrackExpense |
There was a problem hiding this comment.
Please add a test case in the test step to cover this additional change
There was a problem hiding this comment.
I added test case:
- Track a manual distance expense in self DM
- Create a workspace then enable Distance rates feature
- Update the workspace default rate to be different from the rate used in step 5
- Go to self DM > Submit it to someone > Select the workspace from step 6
- Verify error shows "Rate not valid for this workspace"
|
@gijoe0295 Also please update the latest main to trigger failed test again |
|
@gijoe0295 Could you please check the failed test? I don't see It happens on other PRs |
heyjennahay
left a comment
There was a problem hiding this comment.
No concern with product change
|
@gijoe0295 Kindly bump |
|
@DylanDylann Thanks for the bump. It's fixed now after merging main |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppScreen.Recording.2025-11-21.at.10.40.14.movAndroid: mWeb ChromeScreen.Recording.2025-11-21.at.10.35.45.moviOS: HybridAppScreen.Recording.2025-11-21.at.10.38.02.moviOS: mWeb SafariScreen.Recording.2025-11-21.at.10.31.40.movUploading Screen Recording 2025-11-21 at 10.31.40.mov… MacOS: Chrome / SafariScreen.Recording.2025-11-21.at.10.28.23.movMacOS: DesktopScreen.Recording.2025-11-21.at.10.33.48.mov |
|
✋ 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/Beamanator in version: 9.2.62-0 🚀
|
|
🚀 Deployed to production by https://github.com/marcaaron in version: 9.2.62-5 🚀
|

Explanation of Change
When first being invited to a workspace, the distance rates data
policy.customUnitsis not available yet -> Distance expense gets initiated with P2P rate instead -> BE fails with "The selected rate has been deleted" error. This data is only available when user reaches the confirmation step. This PR updates the correct distance rate in confirmation step when it's available.Fixed Issues
$ #73800
PROPOSAL: #73800 (comment)
Tests
$0.7/milefor USD workspaces for example)Offline tests
NA
QA Steps
// TODO: These must be filled out, or the issue title must include "[No QA]."
Same as tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Screen.Recording.2025-11-10.at.23.19.27.mov
Android: mWeb Chrome
Screen.Recording.2025-11-10.at.23.23.01.mp4
iOS: Native
Screen.Recording.2025-11-10.at.23.11.56.mp4
iOS: mWeb Safari
Screen.Recording.2025-11-10.at.23.13.47.mp4
MacOS: Chrome / Safari
Screen.Recording.2025-11-10.at.23.09.16.mp4
Screen.Recording.2025-11-12.at.00.58.05.mov
MacOS: Desktop
Screen.Recording.2025-11-10.at.23.14.35.mp4