Skip to content

[$250] Workspace - Auto-approve and auto-pay still toggle on after downgrading the Workspace #78845

Closed

Description

@jponikarchuk

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.2.92-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from BrowserStack: Exploratory #77188
Email or phone of affected tester (no customers): N/A
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Windows 10/Chrome
App Component: Workspace Settings

Action Performed:

Preconditions: The collect workspace has connected to a bank account

  1. Open the NewDot app
  2. Navigate to the Workflow section
  3. Toggle on the Auto-approve compliant report
  4. Click the Upgrade button on the RHP
  5. Toggle on the Auto-pay approve report
  6. Go to the Overview and downgrade the Workspace to Collect
  7. Navigate back to the Workflow section
  8. Toggle off and on the Auto-approve compliant report (observe that it has required an upgrade RHP)

Expected Result:

The Auto-approve compliant report and Auto-pay approve report are toggle off, because when toggle off and toggle on again, it requires upgrading the Workspace to Control

Actual Result:

The Auto-approve compliant report and Auto-pay approve report are still on after downgrading the Workspace to Collect

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

1.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022008645430344423839
  • Upwork Job ID: 2008645430344423839
  • Last Price Increase: 2026-01-13
Issue OwnerCurrent Issue Owner: @thienlnam

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jan 5, 2026
  2. melvin-bot commented on Jan 5, 2026

    @melvin-bot

    Triggered auto assignment to @JmillsExpensify (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.

  3. mkzie2 commented on Jan 5, 2026

    @mkzie2
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    The Auto-approve compliant report and Auto-pay approve report are still on after downgrading the Workspace to Collect

    What is the root cause of that problem?

    When downgrading workspace, we don't optimistically set policy.shouldShowAutoApprovalOptions and policy.shouldShowAutoReimbursementLimitOption to false, and also BE doesn't update that.

    What changes do you think we should make in order to solve the problem?

    1. BE should return policy.shouldShowAutoApprovalOptions and policy.shouldShowAutoReimbursementLimitOption as false for Policy_DowngradeToTeam API

    2. FE should optimistically set policy.shouldShowAutoApprovalOptions and policy.shouldShowAutoReimbursementLimitOption to false for Policy_DowngradeToTeam API:

        const optimisticData: OnyxUpdate[] = [
            {
                onyxMethod: Onyx.METHOD.MERGE,
                key: `policy_${policyID}`,
                value: {
                    isPendingDowngrade: true,
                    type: CONST.POLICY.TYPE.TEAM,
                    isAttendeeTrackingEnabled: null,
                    shouldShowAutoApprovalOptions: false,
                    shouldShowAutoReimbursementLimitOption: false
                    pendingFields: {
                        shouldShowAutoApprovalOptions: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
                        shouldShowAutoReimbursementLimitOption:  CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
                    }
                }, 
            },
        ];

    const optimisticData: OnyxUpdate[] = [
    {
    onyxMethod: Onyx.METHOD.MERGE,
    key: `policy_${policyID}`,
    value: {
    isPendingDowngrade: true,
    type: CONST.POLICY.TYPE.TEAM,
    isAttendeeTrackingEnabled: null,
    },
    },
    ];

    Also modify successData and failureData, respectively.

    We should consider resetting related props, like preventSelfApproval, autoApproval, autoReimbursement to default values.

    We should also check and disable all control-only features for this API.

    What alternative solutions did you explore? (Optional)

    Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

  4. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Jan 6, 2026
  5. melvin-bot commented on Jan 6, 2026

    @melvin-bot
  6. changed the title [-]Workspace - Auto-approve and auto-pay still toggle on after downgrading the Workspace[/-] [+][$250] Workspace - Auto-approve and auto-pay still toggle on after downgrading the Workspace[/+] on Jan 6, 2026
  7. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Jan 6, 2026
  8. melvin-bot commented on Jan 6, 2026

    @melvin-bot

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

  9. twinkle-react commented on Jan 7, 2026

    @twinkle-react

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    After a workspace is downgraded from Control to Collect (TEAM), the auto-approve and auto-pay toggles in the Workflow section can remain “on” even though they should no longer be available.
    The toggles appear enabled because the client Onyx entry still contains stale Control-only fields.


    What is the root cause of that problem?

    • The server sends a downgraded Collect (TEAM) policy payload without Control-only fields.
    • Onyx.METHOD.MERGE is used to apply the update, which preserves existing keys in the current Onyx entry.
    • As a result, fields like shouldShowAutoApprovalOptions and shouldShowAutoReimbursementLimitOption remain in Onyx, making the UI think the toggles are still available.
    • The Onyx policy entry is now a mix of TEAM type with stale Control flags, causing the toggles to remain enabled incorrectly.

    What changes do you think we should make in order to solve the problem?

    Treat policy updates coming from Policy_DowngradeToTeam as authoritative and replace the Onyx entry instead of merging:

    1. In src/libs/actions/OnyxUpdates.ts, detect downgrade responses.
    2. Rewrite any policy update for a TEAM type to use Onyx.METHOD.SET rather than MERGE.
    3. This ensures the Onyx entry matches the server payload exactly, removing any stale Control-only flags.

    Pseudo-diff :

    // src/libs/actions/OnyxUpdates.ts
    const normalizePolicyDowngrade = (updates = []) =>
        request?.command === WRITE_COMMANDS.DOWNGRADE_TO_TEAM
            ? updates.map((update) => {
                  const isPolicyUpdate = typeof update.key === 'string' && update.key.startsWith(ONYXKEYS.COLLECTION.POLICY);
                  const isDowngradedPolicy = isPolicyUpdate && (update.value as Policy)?.type === CONST.POLICY.TYPE.TEAM;
                  return isPolicyUpdate && isDowngradedPolicy
                      ? {...update, onyxMethod: Onyx.METHOD.SET}
                      : update;
              })
            : updates;
    
    const normalizedOnyxData = normalizePolicyDowngrade(response.onyxData);
    const onyxDataUpdatePromise = normalizedOnyxData?.length
        ? updateHandler(normalizedOnyxData)
        : Promise.resolve();

    What alternative solutions did you explore? (Optional)

    • Manually clearing Control-only fields on the client: rejected because it’s fragile and duplicates server logic.
  10. KocaPepsi commented on Jan 7, 2026

    @KocaPepsi
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    Auto-approve and auto-pay still toggle on after downgrading the Workspace

    What is the root cause of that problem?

    This issue started occurring after we moved the enforcement settings to the Workflow section (#75117)

    In the previous flow before PR #75117, the enforcement settings were under Rules. When we downgrade a workspace, Rules becomes disable, so we don't see the enforcement settings anymore because they are part of Rules.

    "areRulesEnabled": false,

    After we moved the enforcement settings to the Workflow section, they will always be shown, regardless of whether Rules is enabled or disabled.

    <ExpenseReportRulesSection policyID={route.params.policyID} />

    What changes do you think we should make in order to solve the problem?

    To resolve this issue, we have two options:

    Option 1: we need backend update when we downgrade workspace then reset preventSelfApproval , shouldShowAutoApprovalOptions, shouldShowAutoReimbursementLimitOption to false

    Option 2: Follow the previous flow, if Rules is disabled, hide the enforcement settings. With this approach, we don't need to change any backend logic and we simply update the frontend while keeping the existing backend logic correct.

    <ExpenseReportRulesSection policyID={route.params.policyID} />

    {policy?.areRulesEnabled && <ExpenseReportRulesSection policyID={route.params.policyID} />}

    or

    {isControlPolicy(policy) && <ExpenseReportRulesSection policyID={route.params.policyID} />}

    and remove unused frontend logic

    What alternative solutions did you explore? (Optional)

    Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

  11. huult commented on Jan 7, 2026

    @huult
    Contributor

    @KocaPepsi 's proposal looks promising. Before moving forward, I’d like to ask the internal team to double-check the expected behavior.

    Previously, before we moved the Expense Report Rules section into Workflows, this was the behavior: if we enabled Auto-Approve or Prevent Self-Approval, then downgraded and upgraded again, those values would persist.

    Screen.Recording.2026-01-07.at.21.48.48.mov

    The Auto-approve compliant report and Auto-pay approve report are toggle off, because when toggle off and toggle on again, it requires upgrading the Workspace to Control

    With the new expected behavior, when we downgrade and then upgrade again, Auto-Approve and Prevent Self-Approval will not persist because Auto-approve compliant report and Auto-pay approve are reset during the downgrade. This can be confusing, since these settings are turned off after a downgrade and upgrade. Example:

    Because of that, I think we should hide the Expense Report Rules section in Workflows when the plan type is Collect, and only show it when the plan type is Control, like in the example video:

    Screen.Recording.2026-01-07.at.22.03.25.mov

    @JmillsExpensify @tgolen Because you already have the context (#75117), I’d like to ask what you think. Should we hide the Expense Report Rules section in Workflows, or should we keep it visible but disable the options in that section when the workspace is downgraded?

  12. 27 remaining items

  13. huult commented on Jan 30, 2026

    @huult
    Contributor

    Same as above

  14. melvin-bot commented on Feb 3, 2026

    @melvin-bot

    @thienlnam Still overdue 6 days?! Let's take care of this!

  15. thienlnam commented on Feb 3, 2026

    @thienlnam
    Contributor

    The backend PR is live and deployed - you should have access to that now?

  16. huult commented on Feb 4, 2026

    @huult
    Contributor
    Screen.Recording.2026-02-04.at.09.17.44.mov

    @thienlnam We have a bug. Could you take a look? When downgrading, shouldShowAutoApprovalOptions and shouldShowAutoReimbursementLimitOption sometimes still return true.

  17. thienlnam commented on Feb 4, 2026

    @thienlnam
    Contributor

    Fix is addressed, will be a couple days to deploy to prod

  18. huult commented on Feb 10, 2026

    @huult
    Contributor
    Screen.Recording.2026-02-10.at.21.29.38.mov

    @JmillsExpensify @thienlnam I’ve tested this and it works as expected. Could we re-test and close this ticket?

  19. JmillsExpensify commented on Feb 10, 2026

    @JmillsExpensify
    Contributor

    That's good enough for me! I'll go ahead and close, though are you owed?

  20. huult commented on Feb 11, 2026

    @huult
    Contributor

    That's good enough for me! I'll go ahead and close, though are you owed?

    @JmillsExpensify This is a backend issue, so no.

  21. JmillsExpensify commented on Feb 11, 2026

    @JmillsExpensify
    Contributor

    Ok great thanks!

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

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributorHelp WantedApply this label when an issue is open to proposals by contributors

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions