-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Fix: Error when creating per diem expense after selecting report from different workspace #79939
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
Conversation
… different workspace
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
|
@abzokhattab 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] |
| true, | ||
| ); | ||
|
|
||
| // Clear subrates, and update customUnitID if policy changed for per diem transactions |
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.
❌ CONSISTENCY-5 (docs)
Potential State Inconsistency: If the new policy doesn't have per diem rates enabled (i.e., newCustomUnitID is undefined), the code will clear customUnitRateID and subrates but won't update the customUnitID. This leaves the transaction with a customUnitID from the old policy but no corresponding rate ID or subrates, creating an inconsistent state.
Suggested Fix:
Add validation to ensure the new policy supports per diem before allowing the change:
// Clear subrates, and update customUnitID if policy changed for per diem transactions
if (policyChanged && isPerDiemTransaction) {
if (!newCustomUnitID) {
Log.error('[IOURequestStepReport] New policy does not support per diem rates');
// Consider showing an error to the user or preventing the policy change
return;
}
setCustomUnitID(transaction.transactionID, newCustomUnitID);
setCustomUnitRateID(transaction.transactionID, undefined);
clearSubrates(transaction.transactionID);
}| ); | ||
|
|
||
| // Clear subrates, and update customUnitID if policy changed for per diem transactions | ||
| if (policyChanged && isPerDiemTransaction) { |
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.
@nyomanjyotisa lets change it to
| if (policyChanged && isPerDiemTransaction) { | |
| if (policyChanged && isPerDiemTransaction) { | |
| setCustomUnitID(transaction.transactionID, newCustomUnitID ?? CONST.CUSTOM_UNITS.FAKE_P2P_ID); | |
| setCustomUnitRateID(transaction.transactionID, undefined); | |
| clearSubrates(transaction.transactionID); | |
| } |
as getPerDiemCustomUnit(newPolicy) can return undefined when the policy hasn’t loaded yet (or per-diem units aren’t available), so we should still move the transaction off the old policy’s customUnitID. Using CONST.CUSTOM_UNITS.FAKE_P2P_ID as a placeholder matches existing per-diem flows (e.g. IOURequestStepPerDiemWorkspace.tsx and IOURequestStepDestination.tsx ) and avoids leaving an invalid customUnitID + stale subrates/rate after a policy change.
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.
Sure, I've updated the PR
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppScreen.Recording.2026-01-23.at.01.29.48.movAndroid: mWeb ChromeScreen.Recording.2026-01-23.at.01.30.50.moviOS: HybridAppScreen.Recording.2026-01-23.at.01.28.41.moviOS: mWeb SafariScreen.Recording.2026-01-23.at.01.37.04.movMacOS: Chrome / SafariScreen.Recording.2026-01-23.at.01.26.09.mov |
abzokhattab
left a comment
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
|
✋ 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/tylerkaraszewski in version: 9.3.8-0 🚀
|
|
@nyomanjyotisa this PR is failing with #80415 |
|
@nlemma In this PR, when
Is this expected when both workspace enabled per diem feature? cc @aimane-chnaif @bernhardoj |
|
@nlemma the current PR has not been deployed to production yet. so its not caused by the current change |
|
yes it's expected |
Explanation of Change
Clear subrates, and update
customUnitIDif policy changed for per diem transactionsFixed Issues
$ #78985
PROPOSAL: #78985 (comment)
Tests
Same as QA Steps
Offline tests
Same as QA Steps
QA Steps
Precondition:
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
Android-Native.mp4
Android: mWeb Chrome
Android-mWeb.Chrome.mp4
iOS: Native
iOS-Native.mp4
iOS: mWeb Safari
iOS-mWeb.Safari.mp4
MacOS: Chrome / Safari
MacOS-Chrome.mp4