Skip to content

[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

Closed

Description

@trjExpensify

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


**Version Number:**v9.3.62-7
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from BrowserStack: N/A
Logs: Logs
**Expensify/Expensify Issue URL:**https://github.com/Expensify/Expensify/issues/626851#issuecomment-4307515474
Issue reported by: @NicMendonca
Slack conversation (hyperlinked to channel name): #quality

Action Performed:

Pre-requisites:

  • Control workspace
  • ADVANCED approval
  • userA submits to userB, userB forwardsTo userC
  1. userA submit report to userB
  2. userB approves and forwards the report to userC
  3. Observe the expense fields on the report aren't editable by userA
  4. Admin changes the approver of userA to userC
  5. Observe the expense fields on the report are now editable by userA
  6. 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:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari

Screenshots/Videos

My repro:

2026-04-23_21-12-38.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @mallenexpensify
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022048922812513626776
  • Upwork Job ID: 2048922812513626776
  • Last Price Increase: 2026-05-05
  • Automatic offers:
    • FitseTLT | Reviewer | 111389005

Activity

  1. added
    ExternalAdded to denote the issue can be worked on by a contributor
    BugSomething is broken. Auto assigns a BugZero manager.
    on Apr 28, 2026
  2. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Apr 28, 2026
  3. melvin-bot commented on Apr 28, 2026

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @FitseTLT (External)

  4. 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
  5. melvin-bot commented on Apr 28, 2026

    @melvin-bot
  6. MelvinBot commented on Apr 28, 2026

    @MelvinBot
    Contributor

    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 current submitsTo 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:

    1. 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).
    2. 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:

    Data flow:

    1. userA submits to userB → managerID=userB
    2. userB forwards to userC → managerID=userC, state stays SUBMITTED
    3. Admin changes userA's submitsTo from userB→userC
    4. getSubmitToAccountID() now returns userC (from PolicyUtils.ts:1221-1226)
    5. userC === userC → isAwaitingFirstLevelApproval returns true → fields appear editable
    6. Backend correctly rejects the edit

    Note: 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 this to create a draft PR, @MelvinBot <your feedback> to refine this analysis, or explain why you are rejecting Melvin's proposal.

  7. MobileMage commented on Apr 28, 2026

    @MobileMage
    Contributor

    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.

    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 submitsToAccountID = getSubmitToAccountID(getPolicy(report.policyID), report);
    return isProcessingReport(report) && submitsToAccountID === report.managerID;

    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.

    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 submitsToAccountID = getSubmitToAccountID(getPolicy(report.policyID), report);
    return isProcessingReport(report) && submitsToAccountID === report.managerID;

     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)

    N/A

  8. 15antonian commented on Apr 28, 2026

    @15antonian

    Proposal

    What is the root cause of that problem?

    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:

    const submitsToAccountID = getSubmitToAccountID(getPolicy(report.policyID), report);
    return isProcessingReport(report) && submitsToAccountID === 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.

    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 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.

    Compare branch: https://github.com/Expensify/App/compare/main...15antonian:App:fix/89012-forwarded-action-first-level-check?expand=1

  9. emkhalid commented on Apr 28, 2026

    @emkhalid
    Contributor

    Proposal

    What is the root cause of that problem?

    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.

    // If we deep link to a RHP page, we want to make sure we have the correct full screen route under the overlay.
    if (shouldCheckFullScreenRouteMatching(action)) {
    const newFocusedRoute = findFocusedRoute(stateFromPath);
    if (newFocusedRoute) {
    // getMatchingFullScreenRoute returns a TAB_NAVIGATOR wrapper; unwrap it to get the
    // actual inner tab route (e.g. REPORTS_SPLIT_NAVIGATOR) at the correct index.
    const matchingTabNavigatorRoute = getMatchingFullScreenRoute(newFocusedRoute);
    const matchingTabState = matchingTabNavigatorRoute ? getTabState(matchingTabNavigatorRoute) : undefined;
    const matchingFullScreenRoute = matchingTabState ? (matchingTabState.routes?.at(matchingTabState.index ?? 0) as NavigationPartialRoute | undefined) : undefined;
    // Full-screen routes only exist inside TAB_NAVIGATOR, so look at the active tab directly.
    const tabRoute = currentState.routes.findLast((route) => route.name === NAVIGATORS.TAB_NAVIGATOR);
    const tabState = tabRoute ? getTabState(tabRoute as NavigationPartialRoute) : undefined;
    const lastFullScreenRoute = tabState?.routes?.at(tabState.index ?? 0) as NavigationPartialRoute | undefined;
    if (matchingFullScreenRoute && lastFullScreenRoute && shouldChangeToMatchingFullScreen(newFocusedRoute, matchingFullScreenRoute, lastFullScreenRoute)) {
    // Navigate within the existing TAB_NAVIGATOR (tab switch) rather than pushing a new one.
    const lastRouteInMatchingFullScreen = matchingFullScreenRoute.state?.routes?.at(-1);
    const additionalAction = CommonActions.navigate({
    name: NAVIGATORS.TAB_NAVIGATOR,
    params: {
    screen: matchingFullScreenRoute.name,
    params: lastRouteInMatchingFullScreen ? {screen: lastRouteInMatchingFullScreen.name, params: lastRouteInMatchingFullScreen.params} : matchingFullScreenRoute.params,
    },
    });
    navigation.dispatch(additionalAction);

    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.

    // Deepest `screen` in a `{screen, params}` chain (e.g. WORKSPACE_NAV → WORKSPACE_SPLIT_NAV → WORKSPACE.INITIAL).
    const getPushTargetLeaf = (params: unknown): string | undefined => {
    const p = params as {screen?: unknown; params?: unknown} | undefined;
    if (typeof p?.screen !== 'string') {
    return undefined;
    }
    return getPushTargetLeaf(p.params) ?? p.screen;
    };
    /**
    * Custom tab bar rendered by the BottomTabNavigator. Only receives `state` (not the
    * full BottomTabBarProps) to avoid `descriptors` thrashing memoization.
    * Wrapped in overflow:'visible' so floating buttons (FAB, GPS, Camera) aren't clipped.
    */
    function TabNavigatorBar({state}: Pick<BottomTabBarProps, 'state'>) {
    const {shouldUseNarrowLayout} = useResponsiveLayout();
    const {isBlockingViewVisible} = useFullScreenBlockingViewState();
    const {paddingBottom: safeAreaPaddingBottom} = useSafeAreaPaddings(true);
    const styles = useThemeStyles();
    const StyleUtils = useStyleUtils();
    const activeRoute = state.routes[state.index];
    const selectedTab = ROUTE_TO_NAVIGATION_TAB[activeRoute?.name ?? SCREENS.HOME] ?? NAVIGATION_TABS.HOME;

    Specifically, isAtRoot requires both the real focused leaf from activeRoute.state and the leaf from activeRoute.params to be tab-root screens:

    const isAtRoot = isAtTabRootLevel(getFocusedLeafScreenName(activeRoute?.state)) && isAtTabRootLevel(getPushTargetLeaf(activeRoute?.params));

    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.

    */
    function TabNavigatorBar({state}: Pick<BottomTabBarProps, 'state'>) {
    const {shouldUseNarrowLayout} = useResponsiveLayout();
    const {isBlockingViewVisible} = useFullScreenBlockingViewState();
    const {paddingBottom: safeAreaPaddingBottom} = useSafeAreaPaddings(true);
    const styles = useThemeStyles();
    const StyleUtils = useStyleUtils();
    const activeRoute = state.routes[state.index];
    const selectedTab = ROUTE_TO_NAVIGATION_TAB[activeRoute?.name ?? SCREENS.HOME] ?? NAVIGATION_TABS.HOME;

    Replace it with code that:

    • 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.

  10. github-actions commented on Apr 28, 2026

    @github-actions
    Contributor

    ⚠️ @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).

  11. nabi-ebrahimi commented on Apr 28, 2026

    @nabi-ebrahimi

    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

    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 submitsToAccountID = getSubmitToAccountID(getPolicy(report.policyID), report);
    return isProcessingReport(report) && submitsToAccountID === report.managerID;

    getSubmitToAccountID() reads the live policy employee list, including the current employee.submitsTo value:

    App/src/libs/PolicyUtils.ts

    Lines 1211 to 1242 in 96365e1

    function getManagerAccountID(policy: OnyxEntry<Policy>, expenseReport: OnyxEntry<Report> | {ownerAccountID: number}) {
    const employeeAccountID = expenseReport?.ownerAccountID ?? CONST.DEFAULT_NUMBER_ID;
    const employeeLogin = getLoginByAccountID(employeeAccountID) ?? '';
    const defaultApprover = getDefaultApprover(policy);
    // For policy using the optional or basic workflow, the manager is the policy default approver.
    if (([CONST.POLICY.APPROVAL_MODE.OPTIONAL, CONST.POLICY.APPROVAL_MODE.BASIC] as Array<ValueOf<typeof CONST.POLICY.APPROVAL_MODE>>).includes(getApprovalWorkflow(policy))) {
    return getAccountIDsByLogins([defaultApprover]).at(0) ?? -1;
    }
    const employee = policy?.employeeList?.[employeeLogin];
    if (!employee && !defaultApprover) {
    return -1;
    }
    return getAccountIDsByLogins([employee?.submitsTo ?? defaultApprover]).at(0) ?? -1;
    }
    /**
    * Returns the accountID to whom the given expenseReport submits reports to in the given Policy.
    */
    function getSubmitToAccountID(policy: OnyxEntry<Policy>, expenseReport: OnyxEntry<Report>): number {
    const approvalRules = policy?.rules?.approvalRules;
    if (!isSubmitAndClose(policy) && approvalRules?.length) {
    const ruleApprover = getFirstRuleApprover(approvalRules, expenseReport);
    if (ruleApprover) {
    return getAccountIDsByLogins([ruleApprover]).at(0) ?? -1;
    }
    }
    return getManagerAccountID(policy, expenseReport);

    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():

    App/src/libs/ReportUtils.ts

    Lines 4707 to 4709 in 96365e1

    if (reportPolicy?.type === CONST.POLICY.TYPE.CORPORATE && moneyRequestReport && isSubmitted && isCurrentUserSubmitter(moneyRequestReport)) {
    const isForwarded = getSubmitToAccountID(reportPolicy, moneyRequestReport) !== moneyRequestReport.managerID;
    return !isForwarded;

    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:

    App/src/libs/ReportUtils.ts

    Lines 1173 to 1180 in 96365e1

    let allReportActions: OnyxCollection<ReportActions>;
    Onyx.connect({
    key: ONYXKEYS.COLLECTION.REPORT_ACTIONS,
    waitForCollectionCallback: true,
    callback: (actions) => {
    if (!actions) {
    return;
    }

    And ReportActionsUtils already exposes the FORWARDED action predicate:

    function isForwardedAction(reportAction: OnyxInputOrEntry<ReportAction>): reportAction is ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.FORWARDED> {
    return isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.FORWARDED);
    }

    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.
    • Add hasReportBeenForwardedSinceLastSubmit(report).
    • 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)

  12. 36 remaining items

  13. melvin-bot commented on Jun 1, 2026

    @melvin-bot

    Reviewing label has been removed, please complete the "BugZero Checklist".

  14. melvin-bot commented on Jun 1, 2026

    @melvin-bot

    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:

  15. melvin-bot commented on Jun 1, 2026

    @melvin-bot

    @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]

  16. melvin-bot commented on Jun 4, 2026

    @melvin-bot

    @FitseTLT Whoops! This issue is 2 days overdue. Let's get this updated quick!

  17. melvin-bot commented on Jun 7, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  18. FitseTLT commented on Jun 8, 2026

    @FitseTLT
    Contributor

    BugZero Checklist:

    Regression Test Proposal

    Precondition:

    Create the following accounts:

    • Workspace Owner
    • User A (Submitter)
    • User B (First Approver)
    • User C (Second Approver)

    Test:

    1. Log in as the Workspace Owner.
    2. Create a Control Workspaces.
    3. Invite User A, User B, and User C to the Workspace.
    4. Navigate to Workflows and click Add Approval Workflow.
    5. Configure the approval workflow in Workspace
    6. User A = Submitter, User B = First Approver, User C = Second Approver.
    7. Log in as User A.
    8. Create and submit an expense report in Workspace 1.
    9. Before any approver acts on the report, open the submitted expense report as User A.
    10. Verify the submitter can still edit expense details while the report is only awaiting first-level approval.
    11. Open the expense/transaction secondary menu and verify Delete, Merge, and Hold are available.
    12. Log in as User B and approve the expense report.
    13. Log back in as User A and reopen the same submitted expense report.
    14. Verify the submitter can no longer edit expense details or report fields after the report has been forwarded.
    15. Open the expense/transaction secondary menu and verify Delete, Merge, and Hold are no longer available.
    16. Log in as the Workspace Owner.
    17. Update the approval workflow in Workspace 1:
    18. User C = First Approver, Workspace Owner = Second Approver.
    19. Log back in as User A and reopen the same submitted expense report.
    20. Verify the report remains locked even after the workflow update.
    21. Verify the submitter still cannot edit expense details.
    22. Open the expense/transaction secondary menu and verify Delete, Merge, and Hold are still unavailable.

    Do we agree 👍 or 👎

    Zapier Logs Run ID: 00040eee-febc-a541-c89b-0108b48d3614
  19. mallenexpensify commented on Jun 8, 2026

    @mallenexpensify
    Contributor

    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

  20. nabi-ebrahimi commented on Jun 9, 2026

    @nabi-ebrahimi

    @mallenexpensify, Accepted the offer. thank you.

  21. mallenexpensify commented on Jun 9, 2026

    @mallenexpensify
    Contributor

    @nabi-ebrahimi paid, summary updated above. Thx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

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

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions