Skip to content

Move Copilot to its own top-level menu under Account#89422

Draft
wildan-m wants to merge 6 commits intoExpensify:mainfrom
wildan-m:wildan/89113-copilot-section
Draft

Move Copilot to its own top-level menu under Account#89422
wildan-m wants to merge 6 commits intoExpensify:mainfrom
wildan-m:wildan/89113-copilot-section

Conversation

@wildan-m
Copy link
Copy Markdown
Contributor

@wildan-m wildan-m commented May 2, 2026

Explanation of Change

Customers were having a hard time finding Copilot settings: they were nested deep under Account → Security, and the list of accounts a user can copilot into was only reachable via the avatar account-switcher. This was less intuitive than Classic and led some users to assume they had lost access.

This PR addresses the three changes agreed in the issue:

  1. Promotes Copilot to a dedicated top-level item under Account, positioned between Preferences and Security. The Copilot section is removed from SecuritySettingsPage and lives in a new src/pages/settings/Copilot/CopilotPage.tsx registered as a central-pane settings screen at settings/copilot.
  2. Reorders the Copilot page into two stacked cards — the top card is "Accounts you have access to" (delegators) so the more frequently used list leads the page, and the bottom card is "Accounts that have access to your account" (delegates) along with the existing Add copilot button and change-access / remove popover.
  3. Adds a per-row Switch button in the top card that invokes the same connect({email, delegatedAccess, credentials, session, activePolicyID}) action the avatar account-switcher uses today, with the existing offline / GPS-in-progress guards reused from AccountSwitcher. The button is disabled while the row has a pendingAction, and connect errors render inline via the existing clearDelegatorErrors mechanism.

Three small new translation keys were introduced under the existing delegate namespace: delegate.copilot (menu title), delegate.switch (button label), and delegate.noAccountsToAccess (empty-state subtitle for the top card). All other strings (youCanAccessTheseAccounts, membersCanAccessYourAccount, addCopilot, removeCopilot, copilotDelegatedAccessDescription, etc.) are reused from the existing Security page. The youCanAccessTheseAccounts value was tightened to drop the trailing "via the account switcher" phrasing now that the Switch action is inline.

Fixed Issues

$ #89113
PROPOSAL: #89113 (comment)

Tests

Test data setup

To exercise the delegator (top) card, you'll need an account that has been added as a copilot to at least one other account. From the delegator account, accept the invite via the magic-code flow once — that populates account.delegatedAccess.delegators, which the new top card reads from. The delegate (bottom) card is populated by adding copilots from your own account using "Add copilot".

1. New top-level menu placement

  1. Open the app and navigate to the Account tab.
  2. Verify the menu items appear in this order: Profile, Preferences, Copilot, Security, Wallet, Subscription, etc.
  3. Tap Copilot and verify the URL becomes /settings/copilot and the central pane shows a screen titled "Copilot".

2. Top card — Accounts you have access to

  1. As an account that has at least one delegator, open /settings/copilot.
  2. Verify the top card title is "You can access these accounts:" (no longer trailing "via the account switcher").
  3. Verify each delegator row shows the delegator's avatar, display name, role badge ("Full" or "Limited"), and a right-aligned Switch button.
  4. Tap Switch on a delegator row — verify you are switched into that account (the same outcome as picking that delegator from the avatar account-switcher).
  5. Sign back out and return to your primary account.

3. Top card — empty state

  1. As an account with no delegators, open /settings/copilot.
  2. Verify the top card still renders with the title "You can access these accounts:" and a single non-interactive row reading "You don't have access to any accounts yet."

4. Bottom card — Accounts that can access your account

  1. From the same Copilot page, scroll down to the second card titled "These members can access your account:".
  2. Verify the subtitle reads "Allow other members to access your account. Learn more." with "Learn more" linking to the help article.
  3. If the account has any copilots, verify each row shows the copilot's avatar, name, role badge, and a three-dots icon.
  4. Tap a copilot row → the popover menu shows "Change access level" and "Remove copilot". Both actions navigate / behave exactly as they used to on the Security page.
  5. Tap Add copilot at the bottom of the card — verify it opens the same Add Delegate flow (/settings/security/delegate/add flow) that exists today.

5. Switch button — offline guard

  1. From the top card, turn off your network connection.
  2. Tap Switch on a delegator row.
  3. Verify the "You appear to be offline" confirm modal is shown instead of attempting the switch.

6. Switch button — GPS-in-progress guard

  1. With a GPS trip in progress (start one from a SmartScan / mileage flow that uses GPS tracking), open /settings/copilot.
  2. Tap Switch on a delegator row.
  3. Verify the "Switch account?" GPS warning modal appears. Tap Switch → trip is stopped and the account switch proceeds. Tap Cancel → modal dismisses and you stay on the current account.

7. Security page no longer contains Copilot

  1. Navigate to Account → Security.
  2. Verify the Copilot section (heading "Copilot: Delegated access" plus its two delegate/delegator lists, Add copilot button, and the change-access / remove popover) is fully removed.
  3. Verify the remaining security menu items (Two-factor authentication, Reset MFA, Merge accounts, Lock account / Unlock account, Close account) still render and behave normally.

8. Pending state and inline error

  1. As a delegator-side account, trigger a connect error (e.g. switch with a stale credential). Verify the error renders inline under the corresponding delegator row, and dismissing the row clears the error via the existing clearDelegatorErrors action.
  2. While a delegator row has a pendingAction (mid-add optimistic state), verify the Switch button on that row is disabled.

9. Direct deep link

  1. Visit https://new.expensify.com/settings/copilot directly (or paste it in the URL bar after signing in).
  2. Verify the Copilot page loads in the central pane and the Account → Copilot menu item is highlighted as the active selection.

Offline tests

Same as Tests step 5: with the network turned off, tapping Switch on a delegator row shows the "You appear to be offline" confirmation modal instead of issuing a connect call. Reading the page itself (delegators / delegates lists) works offline — both lists are sourced from the cached account.delegatedAccess Onyx value.

QA Steps

Same as tests.

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 shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • 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)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • 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)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • 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.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • 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

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

Move the Copilot UI out of the Security page into a dedicated central pane,
positioned between Preferences and Security. The new page leads with the
"Accounts you have access to" list (delegators) and adds a per-row Switch
button that mirrors the AccountSwitcher's connect flow, so users can switch
into a delegated account without going through the avatar menu. The Security
page is reduced to genuine security controls (2FA, MFA revoke, merge, lock,
close).
@melvin-bot
Copy link
Copy Markdown

melvin-bot Bot commented May 2, 2026

Hey, I noticed you changed src/languages/en.ts in a PR from a fork. For security reasons, translations are not generated automatically for PRs from forks.

If you want to automatically generate translations for other locales, an Expensify employee will have to:

  1. Look at the code and make sure there are no malicious changes.
  2. Run the Generate static translations GitHub workflow. If you have write access and the K2 extension, you can simply click: [this button]

Alternatively, if you are an external contributor, you can run the translation script locally with your own OpenAI API key. To learn more, try running:

npx ts-node ./scripts/generateTranslations.ts --help

Typically, you'd want to translate only what you changed by running npx ts-node ./scripts/generateTranslations.ts --compare-ref main

@codecov
Copy link
Copy Markdown

codecov Bot commented May 2, 2026

Codecov Report

❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.

Files with missing lines Coverage Δ
src/CONST/index.ts 92.30% <ø> (ø)
src/ROUTES.ts 17.35% <ø> (ø)
src/SCREENS.ts 100.00% <ø> (ø)
...igation/linkingConfig/RELATIONS/SETTINGS_TO_RHP.ts 100.00% <ø> (ø)
src/libs/Navigation/linkingConfig/config.ts 76.92% <ø> (ø)
src/pages/settings/InitialSettingsPage.tsx 0.00% <ø> (ø)
...AppNavigator/Navigators/SettingsSplitNavigator.tsx 12.00% <0.00%> (-0.50%) ⬇️
...c/pages/settings/Security/SecuritySettingsPage.tsx 0.00% <0.00%> (ø)
src/pages/settings/Copilot/CopilotPage.tsx 63.56% <63.56%> (ø)
... and 10 files with indirect coverage changes

The empty-state ('You don't have access to any accounts yet.') under
a 'You can access these accounts:' title read as a contradiction.
Drop the noAccountsToAccess key and only render the top section when
delegators exist. The bottom 'These members can access your account'
card remains visible so users can still add a copilot.
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.

1 participant