Skip to content

[Payment due @ZhenjaHorbach] [Workspace Roles] Lock approval toggle from backend signal instead of card data - #94518

Merged
JmillsExpensify merged 4 commits into
Expensify:mainfrom
ShridharGoel:shridhar-workflows-approval-lock-signal
Aug 28, 2026
Merged

[Payment due @ZhenjaHorbach] [Workspace Roles] Lock approval toggle from backend signal instead of card data#94518
JmillsExpensify merged 4 commits into
Expensify:mainfrom
ShridharGoel:shridhar-workflows-approval-lock-signal

Conversation

@ShridharGoel

@ShridharGoel ShridharGoel commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

The Workspace Workflows page locks the "Add approvals" toggle while the workspace uses Smart Limit Expensify Cards. It derived that lock client-side from the workspace's Expensify Card list (isSmartLimitEnabled), which forced the backend to ship Expensify Card data to everyone who can open the page — including roles that can edit approvals but cannot read the Expensify Card feature (e.g. People admins). That exposed card data they should not see.

The backend now sends a single boolean in a dedicated Onyx collection key, policyApprovalsLockedByExpensifyCard_<policyID> (a standalone key, not a field on the policy object), and stops shipping card data to roles without Expensify Card read access (see the Auth PR). This PR consumes that boolean to lock the approval toggle and removes the Expensify Card reads the page previously used to derive the lock client-side. The Auth PR deploys first, so the boolean is always present by the time this ships.

Auth counterpart: https://github.com/Expensify/Auth/pull/22489

Fixed Issues

$ https://github.com/Expensify/Expensify/issues/644795
PROPOSAL:

Tests

  1. Open a Control workspace where you are an admin. Go to More features and enable Workflows and Expensify Card.
  2. In Workflows, ensure Approvals is enabled.
  3. Issue an Expensify Card to a member with a Smart Limit.
  4. Go to Workspace → Workflows and verify:
    • The Add approvals toggle is on and locked (it cannot be turned off).
    • The approvals subtitle shows the "you can't disable approvals while Smart Limit is on" prompt.
  5. Verify step 4 for a people admin as well.
  6. As an admin, change the member's card limit type away from Smart Limit (or remove the card). Reopen Workflows and verify the Approvals toggle is no longer locked.
  7. As a people admin, verify the Approvals toggle is no longer locked.
  • Verify that no errors appear in the JS console

Offline tests

QA Steps

Same as Tests.

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

MacOS: Chrome / Safari image

Comment thread src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx Outdated
@ShridharGoel
ShridharGoel force-pushed the shridhar-workflows-approval-lock-signal branch from 7df2d38 to d4311db Compare August 19, 2026 13:42
@ShridharGoel
ShridharGoel requested a review from flodnv August 22, 2026 17:24
New Onyx collection key holds a boolean lock signal, no PII.
ExportOnyxStateTest requires every ONYXKEYS collection
value to land in one of the four export buckets.
@ShridharGoel
ShridharGoel marked this pull request as ready for review August 22, 2026 17:29
@ShridharGoel
ShridharGoel requested review from a team as code owners August 22, 2026 17:29
@melvin-bot
melvin-bot Bot requested review from JmillsExpensify and ZhenjaHorbach and removed request for a team August 22, 2026 17:29
@melvin-bot

melvin-bot Bot commented Aug 22, 2026

Copy link
Copy Markdown

@ZhenjaHorbach Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

Comment thread src/pages/workspace/workflows/tabs/WorkflowsApprovalsTab.tsx
@ZhenjaHorbach

ZhenjaHorbach commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
2026-08-25.12.23.08.mov
Android: mWeb Chrome
2026-08-25.12.23.08.mov
iOS: HybridApp
2026-08-25.12.24.22.mov
iOS: mWeb Safari
2026-08-25.12.23.08.mov
MacOS: Chrome / Safari
2026-08-25.12.16.46.mov

@ZhenjaHorbach

Copy link
Copy Markdown
Contributor

Changes look good
Only one minor thing
is that we don't update the toggle and text optimistically
As a result, with network throttling, we can interact with the toggle, and it can cause a few issues
But it's an edge case

2026-08-25.12.19.16.mov

@melvin-bot melvin-bot Bot changed the title [Workspace Roles] Lock approval toggle from backend signal instead of card data [Payment due @ZhenjaHorbach] [Workspace Roles] Lock approval toggle from backend signal instead of card data Aug 25, 2026
@melvin-bot

melvin-bot Bot commented Aug 25, 2026

Copy link
Copy Markdown

🎯 @ZhenjaHorbach, thanks for reviewing and testing this PR! 🎉

A payment issue will be created for your review once this PR is deployed to production.
E/E issue linked to the PR - https://www.github.com/Expensify/Expensify/issues/644795.

If payment is not needed (e.g., regression PR review fix etc), react with 👎 to this comment to prevent the payment issue from being created.

Comment thread src/ONYXKEYS.ts Outdated
// should not be included as part of the policy object. The policy
// object should mirror the data as it's stored in the database.
POLICY_HAS_CONNECTIONS_DATA_BEEN_FETCHED: 'policyHasConnectionsDataBeenFetched_',
POLICY_APPROVALS_LOCKED_BY_EXPENSIFY_CARD: 'policyApprovalsLockedByExpensifyCard_',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed this data storage in the backend PR: https://github.com/Expensify/Auth/pull/23968#discussion_r3870825376

@ShridharGoel
ShridharGoel requested a review from flodnv August 27, 2026 11:23

@flodnv flodnv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@JmillsExpensify JmillsExpensify left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies got behind. LGTM

@JmillsExpensify
JmillsExpensify merged commit 2c46a7c into Expensify:main Aug 28, 2026
35 of 36 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🚧 JmillsExpensify has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/JmillsExpensify in version: 9.4.64-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor

Yes — one help site change is needed, and I've opened it as a draft: #99798

Why

This PR is behavior-neutral on its own. Swapping isSmartLimitEnabled from a client-side derivation over the workspace card list to the backend areApprovalsLockedByExpensifyCard boolean changes how the Approvals toggle learns it should lock, not when it locks. Nothing a member sees changes, so strictly speaking no docs update is forced by the diff.

Reviewing it did surface a real gap, though: the locked-Approvals behavior your code enforces has never been documented. docs/articles/new-expensify/workspaces/Add-Approvals.md covers turning Approvals on and never mentions that it can't be turned off while any Expensify Card in the workspace uses a Smart Limit. An admin who hits the locked toggle has nowhere to go. That's the one gap worth closing, so the docs PR fills it.

What the docs PR adds

One file, docs/articles/new-expensify/workspaces/Add-Approvals.md:

  • A ## How to turn off Approvals when Expensify Cards use a Smart Limit section — why the toggle locks, the in-product message quoted verbatim, and the steps to unlock it.
  • FAQ: Why can't I toggle off Approvals? and Why can't I choose Smart Limit when I issue an Expensify Card? (the reverse dependency, also undocumented).
  • Search keywords for the locked-toggle phrasings members actually type.

Written against docs/HELP_AUTHORING_GUIDELINES.md, docs/HELPSITE_NAMING_CONVENTIONS.md, and docs/TEMPLATE.md. npm run spell-changed passes on the file, which is the docs merge gate.

UI labels verified against dev NewDot web

Overall: pass — every label matched the strings in src/languages/en.ts, with one section-grouping mismatch that belongs to an existing article, not to this change.

Step Status Observation
Approvals toggle title on the Workflows page pass Reads exactly Approvals, not "Add approvals"
Approvals toggle subtitle pass "Require additional approval before authorizing a payment."
Workflows left-menu item pass Reads exactly Workflows
Add-workflow button label pass Reads exactly Add approval workflow
Expensify Card toggle in More features pass Label Expensify Card, under the Spend heading
Workflows toggle section in More features fail Grouped under Manage, not Spend

Worth noting, since your PR description writes the toggle as "Add approvals": the on-screen title is Approvals. The docs use the live label.

Evidence (2)

Workflows page showing the Approvals toggle titled Approvals with subtitle Require additional approval before authorizing a payment.

Workflows page showing the Approvals toggle titled Approvals with subtitle Require additional approval before authorizing a payment.

More features page with the Workflows left-nav item visible

More features page with the Workflows left-nav item visible

Two things I spotted but left alone

Both are pre-existing and outside this PR's scope — flagging rather than bundling:

  • docs/articles/new-expensify/workspaces/Workspace-Workflows.md says to find the Workflows toggle "Under the Spend section". It's under Manage.
  • workspace.expensifyCard.issueCard.disabledApprovalForSmartLimitError in src/languages/en.ts tells members to "enable approvals in Workflows > Add approvals", but the toggle is named Approvals. That's an app copy fix, not a docs one.

@ShridharGoel, please review the linked help site PR and confirm it reflects the current behavior. Then mark the linked help site PR Ready for review


view run

@mitarachim

Copy link
Copy Markdown

@ShridharGoel This PR is failing in step 4 because of a regression issue #99807

Screenshot 2026-08-29 at 6 13 06 AM

The issue is reproducible in: Web,Android

Bug7245599_1787957761059.bandicam_2026-08-29_01-48-14-331.mp4

@mitarachim

Copy link
Copy Markdown

Hello @ShridharGoel , Step 6 says to perform the same step for People Admin. However, People Admin does not have access to the Expensify Card Issuing feature. Does this mean that we only need to verify the approval toggle for People Admin?

image

cc: @ZhenjaHorbach @flodnv @JmillsExpensify

@ShridharGoel

Copy link
Copy Markdown
Contributor Author

Does this mean that we only need to verify the approval toggle for People Admin?

Yes, updated the steps to make it clearer.

@ShridharGoel

Copy link
Copy Markdown
Contributor Author

This PR is failing in step 4 because of a regression issue #99807

Commented here

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants