You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Due for payment 2026-07-01] Per diem - Unable to move per diem to a new report after changing workspace #81307
Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor
Version Number: 9.3.11-25 Reproducible in staging?: Yes Reproducible in production?: Yes If this was caught during regression testing, add the test name, ID and link from BrowserStack:#80948 Email or phone of affected tester (no customers):sdjosdjnosjnsodnjsoi@gmail.com Issue reported by: Applause Internal Team Bug source: Exploratory - Significant User Experience Deterioration Device used: Mac 26.1 / Chrome App Component: Money Requests
Action Performed:
Precondition:
Create two workspaces - A and B.
Workspace A has per diem rates.
Do not enable per diem feature on workspace B.
Go to staging.new.expensify.com
Go to workspace chat A.
Create a per diem expense.
Open the per diem expense.
Click More > Change workspace.
Select workspace B.
After moving per diem report to workspace B, create one more expense (any expense) in the same report.
Select the per diem expense via checkbox.
Click dropdown button > Move expense.
Click Create report.
Expected Result:
The per diem expense will be moved to a new report.
Actual Result:
The per diem expense cannot be moved to a new report after changing workspace.
It disappears from the original report and reappears.
A new empty report is created in workspace chat B.
🚨 Edited by proposal-police: This proposal was edited at 2026-04-28 04:26:54 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
The per diem expense cannot be moved to a new report after changing workspace.
It disappears from the original report and reappears.
A new empty report is created in workspace chat B.
What is the root cause of that problem?
The bug is in IOURequestEditReport.tsx, which handles the bulk "Move expense > Create report" flow (via checkbox selection).
IOURequestEditReportCommon validates the "Create report" action against policyForMovingExpenses?.id — the per-diem-capable policy resolved by usePolicyForMovingExpenses (workspace A):
However, IOURequestEditReport.createReportForPolicy was creating the new report using selectedReportPolicy (workspace B, which does not support per diem):
selectReport is called with the synthetic item {value, keyForList} — missing policyID — so changeTransactionsReport receives policy: undefined.
The backend rejects moving a workspace-A per diem transaction into a workspace-B report.
The optimistic move rolls back, the expense reappears in the original report, and the empty workspace-B report remains.
Additionally, the billing restriction check in createReport was using selectedReport?.policyID (workspace B) instead of policyForMovingExpensesID (workspace A) for per diem transactions, so restriction checks were applied against the wrong workspace.
What changes do you think we should make in order to solve the problem?
Fix IOURequestEditReport.tsx so that validation, report creation, billing restriction checks, and the optimistic move all use the same policy (policyForMovingExpenses):
1. Create the new report with policyForMovingExpenses (not selectedReportPolicy):
With these changes, the entire "Create report" flow — validation, report creation, and the changeTransactionsReport call — consistently uses workspace A (the per-diem-capable workspace), so the backend accepts the move and the expense is transferred successfully.
What alternative solutions did you explore? (Optional)
An alternative would be to pass selectedReport?.policyID to usePolicyForMovingExpenses via an expensePolicyID argument and let the hook resolve the correct per-diem-capable policy, then update createReportForPolicy accordingly. However, the proposed fix is more direct: it removes the selectedReportPolicy detour and ensures consistent policy usage throughout the entire "Create report" flow with minimal changes.
🚨 Edited by proposal-police: This proposal was edited at 2026-02-03 15:26:27 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
Per-diem expenses created under a workspace where per-diem is enabled cannot be moved to a new report after the report is changed to a workspace where per-diem is disabled. The transaction disappears from the original report, a new empty report is created, and the per-diem transaction is not moved.
What is the root cause of that problem?
In this implementation, the earliest incorrect assumption is in src/libs/actions/Report/index.ts inside buildOptimisticChangePolicyData, where the code assumes that a transaction’s per-diem customUnitID remains valid after a report changes policy. The function updates report and currency fields but does not remap or clear transaction.comment.customUnit.customUnitID, which leaves per-diem transactions pointing to a custom unit from the source policy and directly causes the move to fail validation for the destination policy.
What changes do you think we should make in order to solve the problem?
Single invariant (exact)
Guarantee: "After changeReportPolicy (optimistic or final) completes, every per-diem transaction in the moved report has transaction.comment.customUnit.customUnitID that is valid for the destination policy, or transaction.comment.customUnit is cleared when the destination policy does not support per-diem."
Earliest incorrect assumption (first divergence)
File: src/libs/actions/Report/index.ts
Function: buildOptimisticChangePolicyData
Assumption: Transactions' per-diem customUnitID remain valid after changing report policy; the function updates currency and convertedAmount but does not remap or clear comment.customUnit for per-diem transactions.
Smallest shared-layer fix (owner layer)
Modify buildOptimisticChangePolicyData in the same file to normalize per-diem comment.customUnit for each transaction in the report.
If the destination policy supports per-diem and has a per-diem custom unit, remap the per-diem customUnitID to the destination customUnitID.
If the destination policy does not support per-diem, or the transaction has a missing or fake ID, clear comment.customUnit.
Skip the optimistic merge when no change is needed.
Exact code delta and scope
Files changed: src/libs/actions/Report/index.ts
Function modified: buildOptimisticChangePolicyData
Scope size: one file, one function, around 40 lines added, no new files.
Add this import near the other imports at the top of the file.
and before the existing convertedAmount logic inside buildOptimisticChangePolicyData.
// File: src/libs/actions/Report/index.ts// 6a. Normalize per-diem transaction customUnit for the destination policy.// If destination supports per-diem, map to the destination per-diem custom unit.// If destination does not support per-diem, or transaction has missing/fake ID, clear the customUnit.constdestinationHasPerDiem=!!policy?.arePerDiemRatesEnabled&&!isEmpty(policy?.customUnits);constdestinationPerDiemUnit=destinationHasPerDiem
? Object.values(policy.customUnits??{}).find((unit)=>unit.name===CONST.CUSTOM_UNITS.NAME_PER_DIEM_INTERNATIONAL,)
: undefined;for(consttransactionoftransactions){if(!transaction||!isPerDiemRequestUtil(transaction)||!transaction.comment?.customUnit){continue;}constcurrentCustomUnitID=transaction.comment?.customUnit?.customUnitID;constisFakeOrMissing=!currentCustomUnitID||currentCustomUnitID===CONST.CUSTOM_UNITS.FAKE_P2P_ID;constshouldClear=!destinationHasPerDiem||!destinationPerDiemUnit||isFakeOrMissing;// No-op if already mapped to the destination per-diem unitif(!shouldClear&¤tCustomUnitID===destinationPerDiemUnit.customUnitID){continue;}constnewCustomUnit=shouldClear
? null
: {
...(transaction.comment?.customUnit??{}),customUnitID: destinationPerDiemUnit.customUnitID,};optimisticData.push({onyxMethod: Onyx.METHOD.MERGE,key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transaction.transactionID}`,value: {pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,comment: {
...(transaction.comment??{}),customUnit: newCustomUnit,},},});successData.push({onyxMethod: Onyx.METHOD.MERGE,key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transaction.transactionID}`,value: {pendingAction: null,},});// Preserve full original comment for rollbackfailureData.push({onyxMethod: Onyx.METHOD.MERGE,key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transaction.transactionID}`,value: {pendingAction: transaction.pendingAction??null,comment: transaction.comment,},});}
Note risk and ownership
Owner: libs/actions/Report, which already owns report mutation and optimistic updates.
Regression risk is low because the change follows existing optimistic and failure merge patterns in the same function and only affects the report policy change path for per-diem transactions.
Rollback behavior is safe because failureData restores the original transaction.comment.
A no-op guard avoids unnecessary Onyx writes.
What to change (summary)
Add the import line.
Insert the per-diem normalization block immediately after const transactions = getReportTransactions(reportID);.
Keep the change limited to buildOptimisticChangePolicyData in src/libs/actions/Report/index.ts.
What alternative solutions did you explore? (Optional)
Caller-side UI fixes were explored but rejected because they duplicate logic and do not correct inconsistent transaction data created during policy change.
A backend-only fix would require API or data migrations and higher rollout risk, so it is better as a follow-up.
UI-only workarounds that hide validation errors were rejected because they mask the real data issue.
⚠️@annaweber830 Your proposal is a duplicate of an already existing proposal and has been automatically withdrawn to prevent spam. Please review the existing proposals before submitting a new one.
Please re-state the problem that we are trying to solve in this issue.
After changing a per diem report to a workspace that does not have per diem enabled, moving that per diem expense to a new report fails: the expense disappears then reappears, and the newly created report stays empty. We need the move flow to validate against the actual destination policy so we don't create an invalid report and rollback the transaction move.
What is the root cause of that problem?
The create-report flow for moving expenses uses the destination report's policy (the selected report's policy) for per diem transactions, but the per diem validation for “Create report” uses a different policy (derived from usePolicyForMovingExpenses and often pointing to the active workspace). After changing the report to a workspace without per diem, the validation still passes against the active policy, so the UI proceeds to create a new report in the destination policy that cannot accept the per diem custom unit; the server rejects the move and the optimistic update rolls back.
What changes do you think we should make in order to solve the problem?
Align the per diem validation with the policy that will actually be used to create the destination report. For per diem moves, validate against the selected report’s policy ID (the same policy used by the create-report action), so we surface the per diem warning before creating an invalid report and avoid the rollback/empty-report behavior.
What alternative solutions did you explore? (Optional)
Blocking the workspace change for reports that contain per diem transactions when the destination workspace lacks per diem rates. This avoids the inconsistent state entirely, but is a broader behavior change and not limited to the move-expense flow.
🚨 Edited by proposal-police: This proposal was edited at 2026-02-03 16:53:03 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
Users are unable to move a per diem expense to a new report after changing workspaces.
What is the root cause of that problem?
In IOURequestEditReportCommon.tsx, we call usePolicyForMovingExpenses to determine the policy the expense should be moved to. This policy is also displayed under the Create report title.
Inside usePolicyForMovingExpenses, we check whether the policy where the current expense report lives is valid for moving expenses by calling isPolicyValidForMovingExpenses. Within isPolicyValidForMovingExpenses, there is a canSubmitPerDiemExpenseFromWorkspace check. Since the current workspace (workspace B) does not have the per diem feature enabled, isPolicyValidForMovingExpenses returns false.
We then check whether the user can submit a per diem expense to the current active policy. If so, we return the current active policy that has the per diem feature enabled (workspace A). As a result, workspace A is displayed under the Create report button.
In summary, usePolicyForMovingExpenses checks whether the policy where the current report lives is valid for moving a per diem expense. If it is not valid, it returns the current active policy that has the per diem feature enabled. To determine where the current report lives, it uses the expensePolicyID parameter.
However, in IOURequestEditReport.tsx, when the transaction is a per diem expense, we use selectedReportPolicy as the destination policy. selectedReportPolicy represents the policy where the current expense lives, which is workspace B (where the per diem feature is not enabled). Since we cannot move a per diem expense to a policy without the per diem feature, the backend returns an error. As a result, we revert the per diem expense state to its original state and move it back to a report in workspace B.
What we should do instead is create a new report in workspace A (which has the per diem feature enabled) and move the expense there.
What changes do you think we should make in order to solve the problem?
When hasPerDiemTransactions is true, we should move the expense to a policy that has the per diem feature enabled. policyForMovingExpenses is the active policy that has per diem feature enabled, and it is a result of usePolicyForMovingExpenses.
What alternative solutions did you explore? (Optional)
An alternative approach is to pass selectedReport?.policyID to usePolicyForMovingExpenses so it can determine the policy where the current expense lives. If that policy supports per diem expenses, we will use it. if the policy doesn't have per diem feature, usePolicyForMovingExpenses will return the active policy that has a per diem feature enabled which is workspace A.
Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor
Activity
melvin-bot commentedon Feb 3, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @abdulrahuman5196 (
External)melvin-bot commentedon Feb 3, 2026
Triggered auto assignment to @johncschuster (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.daledah commentedon Feb 3, 2026
🚨 Edited by proposal-police: This proposal was edited at 2026-04-28 04:26:54 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
The per diem expense cannot be moved to a new report after changing workspace.
It disappears from the original report and reappears.
A new empty report is created in workspace chat B.
What is the root cause of that problem?
The bug is in
IOURequestEditReport.tsx, which handles the bulk "Move expense > Create report" flow (via checkbox selection).IOURequestEditReportCommonvalidates the "Create report" action againstpolicyForMovingExpenses?.id— the per-diem-capable policy resolved byusePolicyForMovingExpenses(workspace A):App/src/pages/iou/request/step/IOURequestEditReportCommon.tsx
Lines 243 to 248 in 7e86ce4
However,
IOURequestEditReport.createReportForPolicywas creating the new report usingselectedReportPolicy(workspace B, which does not support per diem):App/src/pages/iou/request/step/IOURequestEditReport.tsx
Line 129 in 7e86ce4
This mismatch means:
selectReportis called with the synthetic item{value, keyForList}— missingpolicyID— sochangeTransactionsReportreceivespolicy: undefined.Additionally, the billing restriction check in
createReportwas usingselectedReport?.policyID(workspace B) instead ofpolicyForMovingExpensesID(workspace A) for per diem transactions, so restriction checks were applied against the wrong workspace.What changes do you think we should make in order to solve the problem?
Fix
IOURequestEditReport.tsxso that validation, report creation, billing restriction checks, and the optimistic move all use the same policy (policyForMovingExpenses):1. Create the new report with
policyForMovingExpenses(notselectedReportPolicy):2. Pass
policyIDin the synthetic list item sochangeTransactionsReportreceives the correct policy:selectReport( { value: optimisticReport.reportID, keyForList: optimisticReport.reportID, + policyID: optimisticReport.policyID, }, optimisticReport, );3. Use
policyForMovingExpensesIDfor billing restriction checks:With these changes, the entire "Create report" flow — validation, report creation, and the
changeTransactionsReportcall — consistently uses workspace A (the per-diem-capable workspace), so the backend accepts the move and the expense is transferred successfully.What alternative solutions did you explore? (Optional)
An alternative would be to pass
selectedReport?.policyIDtousePolicyForMovingExpensesvia anexpensePolicyIDargument and let the hook resolve the correct per-diem-capable policy, then updatecreateReportForPolicyaccordingly. However, the proposed fix is more direct: it removes theselectedReportPolicydetour and ensures consistent policy usage throughout the entire "Create report" flow with minimal changes.twinkle-react commentedon Feb 3, 2026
🚨 Edited by proposal-police: This proposal was edited at 2026-02-03 15:26:27 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
Per-diem expenses created under a workspace where per-diem is enabled cannot be moved to a new report after the report is changed to a workspace where per-diem is disabled. The transaction disappears from the original report, a new empty report is created, and the per-diem transaction is not moved.
What is the root cause of that problem?
In this implementation, the earliest incorrect assumption is in
src/libs/actions/Report/index.tsinsidebuildOptimisticChangePolicyData, where the code assumes that a transaction’s per-diemcustomUnitIDremains valid after a report changes policy. The function updates report and currency fields but does not remap or cleartransaction.comment.customUnit.customUnitID, which leaves per-diem transactions pointing to a custom unit from the source policy and directly causes the move to fail validation for the destination policy.What changes do you think we should make in order to solve the problem?
Single invariant (exact)
Guarantee: "After changeReportPolicy (optimistic or final) completes, every per-diem transaction in the moved report has transaction.comment.customUnit.customUnitID that is valid for the destination policy, or transaction.comment.customUnit is cleared when the destination policy does not support per-diem."
Earliest incorrect assumption (first divergence)
File: src/libs/actions/Report/index.ts
Function: buildOptimisticChangePolicyData
Assumption: Transactions' per-diem customUnitID remain valid after changing report policy; the function updates currency and convertedAmount but does not remap or clear comment.customUnit for per-diem transactions.
Smallest shared-layer fix (owner layer)
Modify buildOptimisticChangePolicyData in the same file to normalize per-diem comment.customUnit for each transaction in the report.
If the destination policy supports per-diem and has a per-diem custom unit, remap the per-diem customUnitID to the destination customUnitID.
If the destination policy does not support per-diem, or the transaction has a missing or fake ID, clear comment.customUnit.
Skip the optimistic merge when no change is needed.
Exact code delta and scope
Files changed: src/libs/actions/Report/index.ts
Function modified: buildOptimisticChangePolicyData
Scope size: one file, one function, around 40 lines added, no new files.
Add this import near the other imports at the top of the file.
Insert this block immediately after:
const transactions = getReportTransactions(reportID);and before the existing convertedAmount logic inside
buildOptimisticChangePolicyData.Note risk and ownership
Owner: libs/actions/Report, which already owns report mutation and optimistic updates.
Regression risk is low because the change follows existing optimistic and failure merge patterns in the same function and only affects the report policy change path for per-diem transactions.
Rollback behavior is safe because failureData restores the original transaction.comment.
A no-op guard avoids unnecessary Onyx writes.
What to change (summary)
Add the import line.
Insert the per-diem normalization block immediately after
const transactions = getReportTransactions(reportID);.Keep the change limited to
buildOptimisticChangePolicyDatainsrc/libs/actions/Report/index.ts.What alternative solutions did you explore? (Optional)
Caller-side UI fixes were explored but rejected because they duplicate logic and do not correct inconsistent transaction data created during policy change.
A backend-only fix would require API or data migrations and higher rollout risk, so it is better as a follow-up.
UI-only workarounds that hide validation errors were rejected because they mask the real data issue.
github-actions commentedon Feb 3, 2026
annaweber830 commentedon Feb 3, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
After changing a per diem report to a workspace that does not have per diem enabled, moving that per diem expense to a new report fails: the expense disappears then reappears, and the newly created report stays empty. We need the move flow to validate against the actual destination policy so we don't create an invalid report and rollback the transaction move.
What is the root cause of that problem?
The create-report flow for moving expenses uses the destination report's policy (the selected report's policy) for per diem transactions, but the per diem validation for “Create report” uses a different policy (derived from
usePolicyForMovingExpensesand often pointing to the active workspace). After changing the report to a workspace without per diem, the validation still passes against the active policy, so the UI proceeds to create a new report in the destination policy that cannot accept the per diem custom unit; the server rejects the move and the optimistic update rolls back.App/src/pages/iou/request/step/IOURequestEditReportCommon.tsx
Lines 214 to 219 in abb2606
What changes do you think we should make in order to solve the problem?
Align the per diem validation with the policy that will actually be used to create the destination report. For per diem moves, validate against the selected report’s policy ID (the same policy used by the create-report action), so we surface the per diem warning before creating an invalid report and avoid the rollback/empty-report behavior.
App/src/pages/iou/request/step/IOURequestEditReportCommon.tsx
Lines 214 to 219 in abb2606
Updated code:
What alternative solutions did you explore? (Optional)
etCoderDysto commentedon Feb 3, 2026
🚨 Edited by proposal-police: This proposal was edited at 2026-02-03 16:53:03 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
Users are unable to move a per diem expense to a new report after changing workspaces.
What is the root cause of that problem?
In
IOURequestEditReportCommon.tsx, we callusePolicyForMovingExpensesto determine the policy the expense should be moved to. This policy is also displayed under the Create report title.App/src/pages/iou/request/step/IOURequestEditReportCommon.tsx
Line 86 in 55fc2d9
Inside
usePolicyForMovingExpenses, we check whether the policy where the current expense report lives is valid for moving expenses by callingisPolicyValidForMovingExpenses. WithinisPolicyValidForMovingExpenses, there is acanSubmitPerDiemExpenseFromWorkspacecheck. Since the current workspace (workspace B) does not have the per diem feature enabled,isPolicyValidForMovingExpensesreturnsfalse.App/src/hooks/usePolicyForMovingExpenses.ts
Lines 49 to 53 in d9cbf6e
We then check whether the user can submit a per diem expense to the current active policy. If so, we return the current active policy that has the per diem feature enabled (workspace A). As a result, workspace A is displayed under the Create report button.
App/src/hooks/usePolicyForMovingExpenses.ts
Lines 56 to 59 in d9cbf6e
In summary,
usePolicyForMovingExpenseschecks whether the policy where the current report lives is valid for moving a per diem expense. If it is not valid, it returns the current active policy that has the per diem feature enabled. To determine where the current report lives, it uses theexpensePolicyIDparameter.However, in
IOURequestEditReport.tsx, when the transaction is a per diem expense, we useselectedReportPolicyas the destination policy.selectedReportPolicyrepresents the policy where the current expense lives, which is workspace B (where the per diem feature is not enabled). Since we cannot move a per diem expense to a policy without the per diem feature, the backend returns an error. As a result, we revert the per diem expense state to its original state and move it back to a report in workspace B.What we should do instead is create a new report in workspace A (which has the per diem feature enabled) and move the expense there.
App/src/pages/iou/request/step/IOURequestEditReport.tsx
Line 111 in 94c13c8
What changes do you think we should make in order to solve the problem?
When
hasPerDiemTransactionsistrue, we should move the expense to a policy that has the per diem feature enabled.policyForMovingExpensesis the active policy that has per diem feature enabled, and it is a result ofusePolicyForMovingExpenses.App/src/pages/iou/request/step/IOURequestEditReport.tsx
Line 111 in 94c13c8
What alternative solutions did you explore? (Optional)
An alternative approach is to pass
selectedReport?.policyIDtousePolicyForMovingExpensesso it can determine the policy where the current expense lives. If that policy supports per diem expenses, we will use it. if the policy doesn't have per diem feature,usePolicyForMovingExpenseswill return the active policy that has a per diem feature enabled which is workspace A.App/src/pages/iou/request/step/IOURequestEditReport.tsx
Line 55 in 94c13c8
We can then use
policyForMovingExpensesdirectly as the destination policy:App/src/pages/iou/request/step/IOURequestEditReport.tsx
Line 112 in 94c13c8
Note: this approach will mirror the same approach we are using
IOURequestEditReportCommon.tsxApp/src/pages/iou/request/step/IOURequestEditReportCommon.tsx
Line 86 in 55fc2d9
Alternative solution 2
We can filter out policy that doesn't have perdiem feature when we change the workspace of a per diem expense in step 5
App/src/pages/ReportChangeWorkspacePage.tsx
Line 145 in 97207e5
Result Video
Screen.Recording.2026-02-03.at.9.56.22.at.night.mp4
etCoderDysto commentedon Feb 13, 2026
Hi @abdulrahuman5196, I think Melvin automation is failing here - it is not commenting on the issue to move it forward.
61 remaining items
madmax330 commentedon Jun 30, 2026
LGTM
melvin-bot commentedon Jun 30, 2026
Triggered auto assignment to @mallenexpensify (
Awaiting Payment)melvin-bot commentedon Jun 30, 2026
Payment Summary
Upwork Job
BugZero Checklist (@mallenexpensify)
mallenexpensify commentedon Jul 2, 2026
Payment Summary
Contributor: @daledah due $250 via NewDot
Contributor+: @abdulrahuman5196 due $250 via NewDot
^ Test case created. Thx
laurenreidexpensify commentedon Jul 6, 2026
$250 approved for @abdulrahuman5196
quinthar commentedon Sep 26, 2026
Approved $250 to @daledah