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-06-08] [$250] Submitter incorrectly appears to be able to edit expenses after the approval workflow is updated to have the forwardsTo become the submitsTo #89012
Observe the expense fields on the report aren't editable by userA
Admin changes the approver of userA to userC
Observe the expense fields on the report are now editable by userA
userA edits an expense field and hits an error.
Expected Result:
The expenses on the report shouldn't become editable after the approval workflow update.
Actual Result:
When the approval workflow is updated such that the forwardsTo now becomes the submitter's submitsTo, the front-end incorrectly allows editing fields, but the backend blocks it and returns an error.
Note: Melvin seems to think this is a mismatch with logic in getSubmitToAccountID and isAwaitingFirstLevelApproval
Workaround:
N/A
Platforms:
Select the officially supported platforms where the issue was reproduced:
changed the title [-]Submitter incorrectly appears to be able to edit expenses after the approval workflow is updated to have the forwardsTo become the submitsTo[/-][+][$250] Submitter incorrectly appears to be able to edit expenses after the approval workflow is updated to have the forwardsTo become the submitsTo[/+]on Apr 28, 2026
isAwaitingFirstLevelApproval (ReportUtils.ts:2022-2031) determines whether a submitted report is still at first-level approval by comparing the currentsubmitsTo value from the live policy (via getSubmitToAccountID) against report.managerID. When a report is forwarded from userB→userC, managerID changes to userC but stateNum/statusNum stay SUBMITTED. If an admin then changes userA's submitsTo from userB to userC, getSubmitToAccountID returns userC — matching managerID — so isAwaitingFirstLevelApproval incorrectly returns true, making the report appear editable.
The same pattern exists in canEditMoneyRequest (ReportUtils.ts:4707-4709), which independently checks getSubmitToAccountID(policy, report) !== managerID to infer forwarding status.
What changes do you think we should make in order to solve the problem?
The isAwaitingFirstLevelApproval function and the isForwarded check in canEditMoneyRequest should not infer forwarding status by comparing live policy configuration against report.managerID. Instead, they should check the report's action history for an APPROVED action (which represents a forward in the advanced approval workflow). If an APPROVED action exists from a prior approver, the report has been forwarded regardless of the current policy submitsTo setting.
Specifically:
In ReportUtils.ts:2029-2031: Replace the submitsToAccountID === report.managerID check with a check that verifies no APPROVED action exists in the report's history (i.e., the report has not yet been forwarded by any approver).
In ReportUtils.ts:4707-4709: Replace the getSubmitToAccountID !== managerID check with the same history-based approach, or call isAwaitingFirstLevelApproval directly for consistency.
This makes the forwarding determination based on what actually happened to the report rather than the current policy configuration.
What alternative solutions did you explore? (Optional)
An alternative would be to store the original submitsTo accountID on the report at submission time and compare against that stored value. However, this would require a backend change to persist the field, whereas checking report action history uses data already available on the client.
Supporting evidence
Affected code paths — isAwaitingFirstLevelApproval gates at least 6 editability checks:
Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, @MelvinBot <your feedback> to refine this analysis, or explain why you are rejecting Melvin's proposal.
Please re-state the problem that we are trying to solve in this issue.
When an advanced-approval report has already been forwarded by the first-level approver to a second-level approver, and an admin then changes the submitter's submitsTo to point directly at that same second-level approver, the front-end incorrectly treats the report as still awaiting first-level approval and re-enables expense editing for the submitter.
What is the root cause of that problem?
isAwaitingFirstLevelApproval determines whether a submitter can edit a processing report by comparing the current policy's submitsToAccountID against report.managerID. The logic assumes: "if the person currently holding the report is the same as who the submitter currently submits to, it must still be at the first level." This breaks when the workflow is changed after submission. In the bug scenario, userB approves and forwards the report to userC, setting report.managerID = userC. Then the admin changes userA's submitsTo from userB to userC. Now getSubmitToAccountID returns userC and report.managerID is also userC, so the function returns true even though the report has already been approved and forwarded past the first level.
The mismatch is that the check compares the current policy state (who submitsTo now points to) against the current report state (current manager), without accounting for the fact that the current manager may have been reached via a forward chain, not via first submission.
What changes do you think we should make in order to solve the problem?
In isAwaitingFirstLevelApproval, after confirming submitsToAccountID === report.managerID, add an additional check for advanced approval mode: verify that the submitsToAccountID has not already forwarded the report. This is detectable by checking whether report.managerID is the account that the current submitsToAccountID would forward to — if so, the manager slot was reached via forwarding, not direct submission, and the report is past first-level approval.
A simpler and equally correct approach is to check the forwardsTo field of the employee whose accountID equals submitsToAccountID. If the current report.managerID is that employee's forwardsTo (or overLimitForwardsTo), the report has already been forwarded and is not at first-level approval.
function isAwaitingFirstLevelApproval(report: OnyxEntry<Report>): boolean {
if (!report) {
return false;
}
// This will be fixed as part of https://github.com/Expensify/Expensify/issues/507850
// eslint-disable-next-line @typescript-eslint/no-deprecated
const policy = getPolicy(report.policyID);
const submitsToAccountID = getSubmitToAccountID(policy, report);
- return isProcessingReport(report) && submitsToAccountID === report.managerID;+ if (!isProcessingReport(report) || submitsToAccountID !== report.managerID) {+ return false;+ }++ // In advanced approval mode, also verify the report hasn't already been forwarded.+ // If the current manager is the forwardsTo target of the submitsTo approver, the report+ // was forwarded past the first level and is no longer awaiting first-level approval.+ const submitsToEmail = getLoginsByAccountIDs([submitsToAccountID]).at(0) ?? '';+ const forwardsToEmail = PolicyUtils.getForwardsToAccount(policy, submitsToEmail, report.total ?? 0);+ if (forwardsToEmail) {+ const forwardsToAccountID = getAccountIDsByLogins([forwardsToEmail]).at(0) ?? -1;+ if (forwardsToAccountID === report.managerID) {+ return false;+ }+ }++ return true;
}
This ensures that when submitsToAccountID matches report.managerID only because the policy was updated to align with a post-forward state, the function correctly returns false and keeps expense fields non-editable for the submitter.
What alternative solutions did you explore? (Optional)
The editability check relies on isAwaitingFirstLevelApproval, defined at ReportUtils.ts#L2022–2032. That function calls getSubmitToAccountID, which reads employee.submitsTo from the live policy via getManagerAccountID, and compares the result to report.managerID:
This predicate was designed to answer "has the report been forwarded past the first approver?" by checking whether the policy's direct submitsTo still matches the current approver on the report. It works correctly while the policy is unchanged: before forwarding, both point to userB; after forwarding, submitsToAccountID stays at userB while report.managerID advances to userC, so the comparison returns false and editing is correctly blocked.
The assumption breaks when an admin updates the workflow after forwarding. In the reported scenario, userB's forwardsTo (userC) becomes userA's new submitsTo. Now getSubmitToAccountID reads the updated policy and returns userC's accountID, while report.managerID is also userC (the person who received the forwarded report). The equality submitsToAccountID === report.managerID becomes true, so isAwaitingFirstLevelApproval returns true for a report that has already been forwarded. This causes canEditReportPolicy at ReportUtils.ts#L4770–4782 to unlock expense fields for the submitter, even though the backend correctly rejects any edit attempt.
What changes do you think we should make in order to solve the problem?
The live policy submitsTo is not a reliable forwarding signal after an admin updates the workflow. The authoritative record of forwarding is the FORWARDED report action, written by the backend when an approver forwards a report — its existence means the report has already advanced past the first approver in the current submission cycle.
In isAwaitingFirstLevelApproval in src/libs/ReportUtils.ts, after the existing isProcessingReport && submitsToAccountID === report.managerID checks pass, add a final guard: find the timestamp of the most recent SUBMITTED action for the report (using the already-imported isSubmittedAction), then check whether any FORWARDED action (using isForwardedAction from ReportActionsUtils.ts#L297) has a created timestamp after it. If one does, the report was forwarded in the current cycle and is not awaiting first-level approval, so the function returns false. allReportActions is already subscribed to via Onyx in ReportUtils.ts at line 1174, so no new Onyx subscription is needed. After this fix, the expense fields remain locked for userA regardless of any subsequent policy edits.
Option: Check the approval chain length from getApprovalChain. If the chain has only one entry and that entry matches report.managerID, assume first-level. Rejected because getApprovalChain also reads from the live policy, so after the admin changes the workflow the chain rebuilds around userC and still returns [userC], producing the same false positive. It does not solve the root cause.
Option: Store the original submitsTo accountID on the report at submission time and compare against that instead of the live policy. Rejected because this requires a new Onyx key and a backend API change to persist the at-submission submitsTo; the frontend alone cannot make this change safely, and it is a much broader scope than needed.
Option: Treat any FORWARDED action anywhere in the report's history as a blocker. Rejected because a report can be forwarded in one cycle, then unapproved and re-submitted in a later cycle where it legitimately awaits first-level approval again. Checking against the most recent SUBMITTED action timestamp correctly scopes the check to the current cycle only.
src/libs/Navigation/helpers/linkTo/index.ts writes a deep cross-tab target into the existing TAB_NAVIGATOR route params when opening an RHP whose matching fullscreen route belongs to a different tab.
That code dispatches CommonActions.navigate() with nested {screen, params}. Those params are only an initial child navigation target, but React Navigation keeps them on the tab route after the child stack has already navigated back.
src/libs/Navigation/AppNavigator/Navigators/TabNavigatorBar.tsx then treats those stale params as if they still represent the current focused screen.
In the repro, activeRoute.state eventually returns to a root screen after pressing back, but activeRoute.params still points to the old deep target, such as Settings_Wallet. Since that stale target is not a root tab screen, isAtRoot stays false, shouldHide stays true on narrow layout, and the bottom tab bar/FAB remain hidden.
What changes do you think we should make in order to solve the problem?
We should keep the Android hydration protection from getPushTargetLeaf(activeRoute?.params), but only while the nested target is still pending. Once the target from params has appeared in real nested state, the params have served their purpose and should no longer be allowed to keep the tab bar hidden after back navigation.
The original code in src/libs/Navigation/AppNavigator/Navigators/TabNavigatorBar.tsx always trusts activeRoute.params.
reads the real focused leaf from activeRoute.state
reads the pending push target leaf from activeRoute.params
remembers when the push target has materialized in real state
ignores that params target after it has materialized once
diff --git a/src/libs/Navigation/AppNavigator/Navigators/TabNavigatorBar.tsx b/src/libs/Navigation/AppNavigator/Navigators/TabNavigatorBar.tsx
@@
-import React, {useEffect, useState} from 'react';+import React, {useEffect, useRef, useState} from 'react';
@@
const StyleUtils = useStyleUtils();
const activeRoute = state.routes[state.index];
const selectedTab = ROUTE_TO_NAVIGATION_TAB[activeRoute?.name ?? SCREENS.HOME] ?? NAVIGATION_TABS.HOME;
- // Check both leaves so wrapper hydration doesn't flash the tab bar on the push target (Android).- const isAtRoot = isAtTabRootLevel(getFocusedLeafScreenName(activeRoute?.state)) && isAtTabRootLevel(getPushTargetLeaf(activeRoute?.params));+ const focusedLeaf = getFocusedLeafScreenName(activeRoute?.state);+ const pushTargetLeaf = getPushTargetLeaf(activeRoute?.params);+ const pushTargetKey = activeRoute?.key && pushTargetLeaf ? `${activeRoute.key}-${pushTargetLeaf}` : undefined;+ const materializedPushTargets = useRef<Set<string>>(new Set());++ useEffect(() => {+ if (!pushTargetKey || focusedLeaf !== pushTargetLeaf) {+ return;+ }++ materializedPushTargets.current.add(pushTargetKey);+ }, [focusedLeaf, pushTargetKey, pushTargetLeaf]);++ // Nested screen params are only reliable until the child state focuses that target once.+ // After that, back navigation updates state but leaves params untouched.+ const shouldRespectPushTarget = !!pushTargetKey && !materializedPushTargets.current.has(pushTargetKey);+ const isAtRoot = isAtTabRootLevel(focusedLeaf) && (!shouldRespectPushTarget || isAtTabRootLevel(pushTargetLeaf));
This fixes the issue because getPushTargetLeaf(activeRoute?.params) is still used during the short period before nested state catches up, so the tab bar does not flash on the deep target. After the target appears in activeRoute.state, back navigation is driven by real state, and stale params can no longer keep isAtRoot false.
This is intentionally limited to TabNavigatorBar. It does not change linkTo, root router behavior, RHP dismissal behavior, or tab history.
What alternative solutions did you explore? (Optional)
I considered changing linkTo() to stop writing nested {screen, params} and instead materialize real tab state with a custom root action. That is a valid architectural fix, but it touches more navigation code and adds a new action/type path for a bug that can be fixed at the place where stale params are misread.
I considered always trusting activeRoute.state once it exists and using params only when state is missing. That is smaller, but it can stop respecting a new pending push target if the tab already has old nested state from a previous visit. Tracking when the specific push target has materialized is safer.
I considered restoring the previous tab when closing the RHP. That changes dismissal behavior and does not fix the underlying issue that stale nested params can disagree with current nested state.
I considered adding isBlockingViewVisible to the tab bar animation key. That only addresses a timing/desync concern. The original bug here is that isAtRoot is computed from stale params, so the tab bar can remain hidden even after the animation delay has settled.
⚠️@emkhalid Thanks for your proposal. Please update it to follow the proposal template, as proposals are only reviewed if they follow that format (note the mandatory sections).
The frontend decides whether a submitted corporate report is still awaiting first-level approval by comparing the report’s current manager with the submitter’s current policy approver.
That works only while the workflow is unchanged. In the reported flow, userA originally submits to userB, then userB forwards the report to userC, so report.managerID becomes userC. After an admin updates userA’s workflow so userA now submits directly to userC, getSubmitToAccountID(policy, report) also returns userC. The equality becomes true again, so isAwaitingFirstLevelApproval() incorrectly treats an already-forwarded report as editable.
The same stale inference is duplicated in canEditMoneyRequest():
That second check is important because expense fields and money request edit affordances use canEditMoneyRequest()/canEditFieldOfMoneyRequest(), so fixing only isAwaitingFirstLevelApproval() would still leave part of the edit UI unlocked.
The authoritative frontend signal that the report already moved past first-level approval is the report action history. ReportUtils already has report actions in its module cache:
What changes do you think we should make in order to solve the problem?
Add a small helper in ReportUtils that checks whether the report has a FORWARDED action after the most recent SUBMITTED action. Then use that helper anywhere the current code infers forwarded state from live policy approver equality.
Required changes:
Import isForwardedAction in src/libs/ReportUtils.ts.
Update isAwaitingFirstLevelApproval() to return false when the report has been forwarded since the latest submit.
Update the corporate submitter branch in canEditMoneyRequest() to also block editing when the report has been forwarded since the latest submit.
Add a unit test covering a submitted corporate report where:
current user is the submitter,
report.managerID is userC,
the live policy now has submitter submitsTo userC,
report actions contain SUBMITTED followed by FORWARDED,
both canEditReportPolicy() and canEditMoneyRequest() return false.
Tests to add/run:
Add a focused unit test in tests/unit/ReportUtilsTest.ts for the forwarded-after-submit workflow update case.
Run npm run test -- tests/unit/ReportUtilsTest.ts.
Run npm run typecheck-tsgo.
Run npm run react-compiler-compliance-check check-changed.
Melvin’s proposal correctly identifies both affected gates, but it uses APPROVED as the forwarding signal. The app has a dedicated FORWARDED report action, so the implementation should use isForwardedAction().
15antonian’s proposal correctly identifies FORWARDED after the latest SUBMITTED action as the right signal, but the provided diff only updates isAwaitingFirstLevelApproval(). That misses the duplicated canEditMoneyRequest() corporate submitter check, which still controls expense-field edit affordances.
Checking the current policy’s forwardsTo chain was rejected because it still relies on live workflow configuration. The bug is caused by live workflow configuration changing after submission, so the fix needs to use report history instead.
Screencast.From.2026-05-01.07-40-48.mp4
What alternative solutions did you explore? (Optional)
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.3.89-7 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:
@FitseTLT The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.
Link to discussion:
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
[BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.
Activity
melvin-bot commentedon Apr 28, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @FitseTLT (
External)[-]Submitter incorrectly appears to be able to edit expenses after the approval workflow is updated to have the forwardsTo become the submitsTo[/-][+][$250] Submitter incorrectly appears to be able to edit expenses after the approval workflow is updated to have the forwardsTo become the submitsTo[/+]melvin-bot commentedon Apr 28, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022048922812513626776
MelvinBot commentedon Apr 28, 2026
Proposal
What is the root cause of that problem?
isAwaitingFirstLevelApproval(ReportUtils.ts:2022-2031) determines whether a submitted report is still at first-level approval by comparing the currentsubmitsTovalue from the live policy (viagetSubmitToAccountID) againstreport.managerID. When a report is forwarded from userB→userC,managerIDchanges to userC butstateNum/statusNumstaySUBMITTED. If an admin then changes userA'ssubmitsTofrom userB to userC,getSubmitToAccountIDreturns userC — matchingmanagerID— soisAwaitingFirstLevelApprovalincorrectly returnstrue, making the report appear editable.The same pattern exists in
canEditMoneyRequest(ReportUtils.ts:4707-4709), which independently checksgetSubmitToAccountID(policy, report) !== managerIDto infer forwarding status.What changes do you think we should make in order to solve the problem?
The
isAwaitingFirstLevelApprovalfunction and theisForwardedcheck incanEditMoneyRequestshould not infer forwarding status by comparing live policy configuration againstreport.managerID. Instead, they should check the report's action history for anAPPROVEDaction (which represents a forward in the advanced approval workflow). If anAPPROVEDaction exists from a prior approver, the report has been forwarded regardless of the current policysubmitsTosetting.Specifically:
ReportUtils.ts:2029-2031: Replace thesubmitsToAccountID === report.managerIDcheck with a check that verifies noAPPROVEDaction exists in the report's history (i.e., the report has not yet been forwarded by any approver).ReportUtils.ts:4707-4709: Replace thegetSubmitToAccountID !== managerIDcheck with the same history-based approach, or callisAwaitingFirstLevelApprovaldirectly for consistency.This makes the forwarding determination based on what actually happened to the report rather than the current policy configuration.
What alternative solutions did you explore? (Optional)
An alternative would be to store the original
submitsToaccountID on the report at submission time and compare against that stored value. However, this would require a backend change to persist the field, whereas checking report action history uses data already available on the client.Supporting evidence
Affected code paths —
isAwaitingFirstLevelApprovalgates at least 6 editability checks:canAddOrDeleteTransactionscanEditReportPolicyisReportFieldDisabledcanEditFieldOfMoneyRequestData flow:
managerID=userBmanagerID=userC, state staysSUBMITTEDsubmitsTofrom userB→userCgetSubmitToAccountID()now returns userC (fromPolicyUtils.ts:1221-1226)userC === userC→isAwaitingFirstLevelApprovalreturnstrue→ fields appear editableNote: The existing code already has a comment acknowledging this area needs fixing: "This will be fixed as part of https://github.com/Expensify/Expensify/issues/507850" (line 2027).
Next Steps for Contributor+ team: Reply with
@MelvinBot implement thisto create a draft PR,@MelvinBot <your feedback>to refine this analysis, or explain why you are rejecting Melvin's proposal.MobileMage commentedon Apr 28, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When an advanced-approval report has already been forwarded by the first-level approver to a second-level approver, and an admin then changes the submitter's
submitsToto point directly at that same second-level approver, the front-end incorrectly treats the report as still awaiting first-level approval and re-enables expense editing for the submitter.What is the root cause of that problem?
isAwaitingFirstLevelApprovaldetermines whether a submitter can edit a processing report by comparing the current policy'ssubmitsToAccountIDagainstreport.managerID. The logic assumes: "if the person currently holding the report is the same as who the submitter currently submits to, it must still be at the first level." This breaks when the workflow is changed after submission. In the bug scenario, userB approves and forwards the report to userC, settingreport.managerID = userC. Then the admin changes userA'ssubmitsTofrom userB to userC. NowgetSubmitToAccountIDreturns userC andreport.managerIDis also userC, so the function returnstrueeven though the report has already been approved and forwarded past the first level.App/src/libs/ReportUtils.ts
Lines 2022 to 2031 in e59c062
The mismatch is that the check compares the current policy state (who
submitsTonow points to) against the current report state (current manager), without accounting for the fact that the current manager may have been reached via a forward chain, not via first submission.What changes do you think we should make in order to solve the problem?
In
isAwaitingFirstLevelApproval, after confirmingsubmitsToAccountID === report.managerID, add an additional check for advanced approval mode: verify that thesubmitsToAccountIDhas not already forwarded the report. This is detectable by checking whetherreport.managerIDis the account that the currentsubmitsToAccountIDwould forward to — if so, the manager slot was reached via forwarding, not direct submission, and the report is past first-level approval.A simpler and equally correct approach is to check the
forwardsTofield of the employee whose accountID equalssubmitsToAccountID. If the currentreport.managerIDis that employee'sforwardsTo(oroverLimitForwardsTo), the report has already been forwarded and is not at first-level approval.App/src/libs/ReportUtils.ts
Lines 2022 to 2031 in e59c062
function isAwaitingFirstLevelApproval(report: OnyxEntry<Report>): boolean { if (!report) { return false; } // This will be fixed as part of https://github.com/Expensify/Expensify/issues/507850 // eslint-disable-next-line @typescript-eslint/no-deprecated const policy = getPolicy(report.policyID); const submitsToAccountID = getSubmitToAccountID(policy, report); - return isProcessingReport(report) && submitsToAccountID === report.managerID; + if (!isProcessingReport(report) || submitsToAccountID !== report.managerID) { + return false; + } + + // In advanced approval mode, also verify the report hasn't already been forwarded. + // If the current manager is the forwardsTo target of the submitsTo approver, the report + // was forwarded past the first level and is no longer awaiting first-level approval. + const submitsToEmail = getLoginsByAccountIDs([submitsToAccountID]).at(0) ?? ''; + const forwardsToEmail = PolicyUtils.getForwardsToAccount(policy, submitsToEmail, report.total ?? 0); + if (forwardsToEmail) { + const forwardsToAccountID = getAccountIDsByLogins([forwardsToEmail]).at(0) ?? -1; + if (forwardsToAccountID === report.managerID) { + return false; + } + } + + return true; }This ensures that when
submitsToAccountIDmatchesreport.managerIDonly because the policy was updated to align with a post-forward state, the function correctly returnsfalseand keeps expense fields non-editable for the submitter.What alternative solutions did you explore? (Optional)
N/A
15antonian commentedon Apr 28, 2026
Proposal
What is the root cause of that problem?
The editability check relies on
isAwaitingFirstLevelApproval, defined atReportUtils.ts#L2022–2032. That function callsgetSubmitToAccountID, which readsemployee.submitsTofrom the live policy viagetManagerAccountID, and compares the result toreport.managerID:This predicate was designed to answer "has the report been forwarded past the first approver?" by checking whether the policy's direct
submitsTostill matches the current approver on the report. It works correctly while the policy is unchanged: before forwarding, both point to userB; after forwarding,submitsToAccountIDstays at userB whilereport.managerIDadvances to userC, so the comparison returns false and editing is correctly blocked.The assumption breaks when an admin updates the workflow after forwarding. In the reported scenario, userB's
forwardsTo(userC) becomes userA's newsubmitsTo. NowgetSubmitToAccountIDreads the updated policy and returns userC's accountID, whilereport.managerIDis also userC (the person who received the forwarded report). The equalitysubmitsToAccountID === report.managerIDbecomes true, soisAwaitingFirstLevelApprovalreturns true for a report that has already been forwarded. This causescanEditReportPolicyatReportUtils.ts#L4770–4782to unlock expense fields for the submitter, even though the backend correctly rejects any edit attempt.What changes do you think we should make in order to solve the problem?
The live policy
submitsTois not a reliable forwarding signal after an admin updates the workflow. The authoritative record of forwarding is theFORWARDEDreport action, written by the backend when an approver forwards a report — its existence means the report has already advanced past the first approver in the current submission cycle.In
isAwaitingFirstLevelApprovalinsrc/libs/ReportUtils.ts, after the existingisProcessingReport && submitsToAccountID === report.managerIDchecks pass, add a final guard: find the timestamp of the most recentSUBMITTEDaction for the report (using the already-importedisSubmittedAction), then check whether anyFORWARDEDaction (usingisForwardedActionfromReportActionsUtils.ts#L297) has acreatedtimestamp after it. If one does, the report was forwarded in the current cycle and is not awaiting first-level approval, so the function returns false.allReportActionsis already subscribed to via Onyx inReportUtils.tsat line 1174, so no new Onyx subscription is needed. After this fix, the expense fields remain locked for userA regardless of any subsequent policy edits.Compare branch: https://github.com/Expensify/App/compare/main...15antonian:App:fix/89012-forwarded-action-first-level-check?expand=1
What alternative solutions did you explore?
Option: Check the approval chain length from
getApprovalChain. If the chain has only one entry and that entry matchesreport.managerID, assume first-level. Rejected becausegetApprovalChainalso reads from the live policy, so after the admin changes the workflow the chain rebuilds around userC and still returns[userC], producing the same false positive. It does not solve the root cause.Option: Store the original
submitsToaccountID on the report at submission time and compare against that instead of the live policy. Rejected because this requires a new Onyx key and a backend API change to persist the at-submissionsubmitsTo; the frontend alone cannot make this change safely, and it is a much broader scope than needed.Option: Treat any FORWARDED action anywhere in the report's history as a blocker. Rejected because a report can be forwarded in one cycle, then unapproved and re-submitted in a later cycle where it legitimately awaits first-level approval again. Checking against the most recent SUBMITTED action timestamp correctly scopes the check to the current cycle only.
Compare branch: https://github.com/Expensify/App/compare/main...15antonian:App:fix/89012-forwarded-action-first-level-check?expand=1
emkhalid commentedon Apr 28, 2026
Proposal
What is the root cause of that problem?
src/libs/Navigation/helpers/linkTo/index.tswrites a deep cross-tab target into the existingTAB_NAVIGATORroute params when opening an RHP whose matching fullscreen route belongs to a different tab.App/src/libs/Navigation/helpers/linkTo/index.ts
Lines 195 to 218 in 7e86ce4
That code dispatches
CommonActions.navigate()with nested{screen, params}. Those params are only an initial child navigation target, but React Navigation keeps them on the tab route after the child stack has already navigated back.src/libs/Navigation/AppNavigator/Navigators/TabNavigatorBar.tsxthen treats those stale params as if they still represent the current focused screen.App/src/libs/Navigation/AppNavigator/Navigators/TabNavigatorBar.tsx
Lines 36 to 57 in 7e86ce4
Specifically,
isAtRootrequires both the real focused leaf fromactiveRoute.stateand the leaf fromactiveRoute.paramsto be tab-root screens:In the repro,
activeRoute.stateeventually returns to a root screen after pressing back, butactiveRoute.paramsstill points to the old deep target, such asSettings_Wallet. Since that stale target is not a root tab screen,isAtRootstaysfalse,shouldHidestaystrueon narrow layout, and the bottom tab bar/FAB remain hidden.What changes do you think we should make in order to solve the problem?
We should keep the Android hydration protection from
getPushTargetLeaf(activeRoute?.params), but only while the nested target is still pending. Once the target from params has appeared in real nested state, the params have served their purpose and should no longer be allowed to keep the tab bar hidden after back navigation.The original code in
src/libs/Navigation/AppNavigator/Navigators/TabNavigatorBar.tsxalways trustsactiveRoute.params.App/src/libs/Navigation/AppNavigator/Navigators/TabNavigatorBar.tsx
Lines 49 to 57 in 7e86ce4
Replace it with code that:
activeRoute.stateactiveRoute.paramsThis fixes the issue because
getPushTargetLeaf(activeRoute?.params)is still used during the short period before nested state catches up, so the tab bar does not flash on the deep target. After the target appears inactiveRoute.state, back navigation is driven by real state, and stale params can no longer keepisAtRootfalse.This is intentionally limited to
TabNavigatorBar. It does not changelinkTo, root router behavior, RHP dismissal behavior, or tab history.What alternative solutions did you explore? (Optional)
I considered changing
linkTo()to stop writing nested{screen, params}and instead materialize real tab state with a custom root action. That is a valid architectural fix, but it touches more navigation code and adds a new action/type path for a bug that can be fixed at the place where stale params are misread.I considered always trusting
activeRoute.stateonce it exists and using params only when state is missing. That is smaller, but it can stop respecting a new pending push target if the tab already has old nested state from a previous visit. Tracking when the specific push target has materialized is safer.I considered restoring the previous tab when closing the RHP. That changes dismissal behavior and does not fix the underlying issue that stale nested params can disagree with current nested state.
I considered adding
isBlockingViewVisibleto the tab bar animation key. That only addresses a timing/desync concern. The original bug here is thatisAtRootis computed from stale params, so the tab bar can remain hidden even after the animation delay has settled.github-actions commentedon Apr 28, 2026
nabi-ebrahimi commentedon Apr 28, 2026
Proposal
What is the root cause of that problem?
The frontend decides whether a submitted corporate report is still awaiting first-level approval by comparing the report’s current manager with the submitter’s current policy approver.
That logic is here:
App/src/libs/ReportUtils.ts
Lines 2022 to 2031 in 96365e1
getSubmitToAccountID()reads the live policy employee list, including the currentemployee.submitsTovalue:App/src/libs/PolicyUtils.ts
Lines 1211 to 1242 in 96365e1
That works only while the workflow is unchanged. In the reported flow, userA originally submits to userB, then userB forwards the report to userC, so
report.managerIDbecomes userC. After an admin updates userA’s workflow so userA now submits directly to userC,getSubmitToAccountID(policy, report)also returns userC. The equality becomes true again, soisAwaitingFirstLevelApproval()incorrectly treats an already-forwarded report as editable.The same stale inference is duplicated in
canEditMoneyRequest():App/src/libs/ReportUtils.ts
Lines 4707 to 4709 in 96365e1
That second check is important because expense fields and money request edit affordances use
canEditMoneyRequest()/canEditFieldOfMoneyRequest(), so fixing onlyisAwaitingFirstLevelApproval()would still leave part of the edit UI unlocked.The authoritative frontend signal that the report already moved past first-level approval is the report action history.
ReportUtilsalready has report actions in its module cache:App/src/libs/ReportUtils.ts
Lines 1173 to 1180 in 96365e1
And
ReportActionsUtilsalready exposes theFORWARDEDaction predicate:App/src/libs/ReportActionsUtils.ts
Lines 297 to 299 in 96365e1
What changes do you think we should make in order to solve the problem?
Add a small helper in
ReportUtilsthat checks whether the report has aFORWARDEDaction after the most recentSUBMITTEDaction. Then use that helper anywhere the current code infers forwarded state from live policy approver equality.Required changes:
isForwardedActioninsrc/libs/ReportUtils.ts.hasReportBeenForwardedSinceLastSubmit(report).isAwaitingFirstLevelApproval()to return false when the report has been forwarded since the latest submit.canEditMoneyRequest()to also block editing when the report has been forwarded since the latest submit.report.managerIDis userC,submitsTouserC,SUBMITTEDfollowed byFORWARDED,canEditReportPolicy()andcanEditMoneyRequest()return false.Tests to add/run:
tests/unit/ReportUtilsTest.tsfor the forwarded-after-submit workflow update case.npm run test -- tests/unit/ReportUtilsTest.ts.npm run typecheck-tsgo.npm run react-compiler-compliance-check check-changed.Melvin’s proposal correctly identifies both affected gates, but it uses
APPROVEDas the forwarding signal. The app has a dedicatedFORWARDEDreport action, so the implementation should useisForwardedAction().15antonian’s proposal correctly identifies
FORWARDEDafter the latestSUBMITTEDaction as the right signal, but the provided diff only updatesisAwaitingFirstLevelApproval(). That misses the duplicatedcanEditMoneyRequest()corporate submitter check, which still controls expense-field edit affordances.Checking the current policy’s
forwardsTochain was rejected because it still relies on live workflow configuration. The bug is caused by live workflow configuration changing after submission, so the fix needs to use report history instead.Screencast.From.2026-05-01.07-40-48.mp4
What alternative solutions did you explore? (Optional)
36 remaining items
melvin-bot commentedon Jun 1, 2026
Reviewinglabel has been removed, please complete the "BugZero Checklist".melvin-bot commentedon Jun 1, 2026
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.3.89-7 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:
If no regressions arise, payment will be issued on 2026-06-08. 🎊
For reference, here are some details about the assignees on this issue:
melvin-bot commentedon Jun 1, 2026
@FitseTLT The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]
melvin-bot commentedon Jun 4, 2026
@FitseTLT Whoops! This issue is 2 days overdue. Let's get this updated quick!
melvin-bot commentedon Jun 7, 2026
Triggered auto assignment to @mallenexpensify (
Awaiting Payment)FitseTLT commentedon Jun 8, 2026
BugZero Checklist:
[Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.
Link to comment:https://github.com/Expensify/App/pull/46931/changes#r3373281621
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.
Link to discussion:
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
[BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.
Link to issue: https://github.com/Expensify/Expensify/issues/646576
Regression Test Proposal
Precondition:
Create the following accounts:
Test:
Do we agree 👍 or 👎
Zapier Logs
Run ID: 00040eee-febc-a541-c89b-0108b48d3614mallenexpensify commentedon Jun 8, 2026
Payment Summary
Contributor: @nabi-ebrahimi paid $250 via Upwork
Contributor+: @FitseTLT paid $250 via Upwork
@nabi-ebrahimi can you please accept the job below? Please reply here and tag me once you have.
https://www.upwork.com/jobs/~022048922812513626776
^ Test case created. Thx
nabi-ebrahimi commentedon Jun 9, 2026
@mallenexpensify, Accepted the offer. thank you.
mallenexpensify commentedon Jun 9, 2026
@nabi-ebrahimi paid, summary updated above. Thx.