Skip to content

Hide device management & merge accounts and repurpose close account when copiloting into an agent - #95812

Merged
puneetlath merged 9 commits into
mainfrom
claude-hideSecurityOptionsWhenCopilotingIntoAgent
Jul 13, 2026
Merged

puneetlath merged 9 commits into
mainfrom
claude-hideSecurityOptionsWhenCopilotingIntoAgent

Conversation

@MelvinBot

@MelvinBot MelvinBot commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

When a user copilots into an agent account (acting as a delegate for an agent_*@expensify.ai account), the Security settings page previously showed options that don't apply to an agent and let the user run the normal "close account" flow against the agent.

This PR adjusts the Security page for the "copiloting into an agent" state (isAgentAccount && isActingAsDelegate):

  • Hides "Device management" — it manages a real user's own logged-in devices, which is meaningless for an agent.
  • Hides "Merge accounts" — merging doesn't apply to agent accounts.
  • Repurposes "Close account" — instead of navigating to the usual close-account flow, it now shows a delete confirmation, invokes the DELETE_AGENT command for the agent you're copiloting into, and then ends the copilot session (disconnect), returning you to your own account.

Details:

  • src/pages/settings/Security/SecuritySettingsPage.tsx — adds the isCopilotingIntoAgent guard, conditionally hides the two menu items, and swaps the close-account action for the delete-agent + disconnect flow. The confirmation modal reuses the existing editAgentPage.deleteAgentTitle/deleteAgentMessage copy (same UX as deleting an agent from the Edit agent page).
  • src/libs/actions/Agent.ts — deleteAgent gains an optional shouldNavigateBack param (default true, so existing callers are unaffected). The copilot flow passes false because the delegate transition resets navigation on its own.

Note for reviewer: The "copiloting into an agent" condition is gated on both isAgentAccount and isActingAsDelegate so the delete-agent behavior only applies when a copilot session actually exists (ending the session requires the stashed delegate credentials). Let me know if you'd rather key it on isAgentAccount alone.

Fixed Issues

$ #95726

Tests

  1. Sign in as a user that has at least one agent set up (Settings > Agents).
  2. Go to Settings > Agents, open an agent, and tap Copilot into account to start copiloting into the agent.
  3. Navigate to Settings > Security.
  4. Verify Device management is not shown.
  5. Verify Merge accounts is not shown.
  6. Verify Close account is still shown.
  7. Tap Close account and verify a Delete agent? confirmation modal appears (instead of the usual close-account page).
  8. Tap Delete and verify:
    • the agent is deleted (it no longer appears under Settings > Agents), and
    • the copilot session ends and you are returned to your own account.
  9. Repeat step 7 but tap Cancel and verify nothing is deleted and the copilot session stays active.
  10. Regression: Sign in as a normal (non-copiloting) user, go to Settings > Security, and verify Device management, Merge accounts, and Close account all appear and behave as before (Close account opens the standard close-account flow).
  11. Verify that no errors appear in the JS console.

Offline tests

Same as tests, except for the copilot "Close account" flow: ending a copilot session requires a live network call (DisconnectAsDelegate is a side-effect request that can't be queued offline), so when copiloting into an agent and offline, tapping Close account shows a "You appear to be offline" modal and does not delete the agent or end the copilot session. Verify the modal appears and nothing else happens; the delete flow itself can only be tested online.

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 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 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
CleanShot.2026-07-10.at.11.20.49.mp4

@MelvinBot
MelvinBot requested a review from a team July 10, 2026 13:10
@codecov

codecov Bot commented Jul 10, 2026 •

Copy link
Copy Markdown

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/libs/actions/Agent.ts 80.59% <100.00%> (+0.29%) ⬆️
src/libs/actions/Delegate.ts 30.81% <0.00%> (-0.34%) ⬇️
...c/pages/settings/Security/SecuritySettingsPage.tsx 0.00% <0.00%> (ø)
... and 8 files with indirect coverage changes

@github-actions

Copy link
Copy Markdown
Contributor

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

@MelvinBot

Copy link
Copy Markdown
Contributor Author

🤖 I looked into the failing checks — there's no code fix to push. The only failing check is human-only, and every code/correctness check is green.

Failing check: PR Author Checklist / checklist — this is in MelvinBot's do-not-touch list because it's a human-only gate. It's failing simply because the author checklist boxes are unchecked and the Tests / QA Steps sections still have the // TODO placeholders ("You completed 0 out of 38 checklist items"). I don't fill these out on a human co-author's behalf.

➡️ To clear it: the human co-author fills in the Tests and QA Steps sections and checks the checklist boxes, then marks the PR ready for review.

Everything code-related passed: typecheck, all 8 test jobs, knip, Storybook tests, ESLint, React Compiler, Oxfmt, Bun tests, unused-styles, spellcheck, all build variants, and signed-commits.

Still running (not failures): baseline-perf-tests and branch-perf-tests are reassure performance benchmarks (started ~13:10, they take 20-30 min). These are informational comparisons, not pass/fail correctness gates — nothing to fix here via code.

@github-actions

This comment has been minimized.

@MelvinBot

Copy link
Copy Markdown
Contributor Author

🤖 Fixed the failing ESLint check and pushed to the branch.

Failure: src/DelegateAccessHandler.tsx:38 — Expected 'undefined' and instead saw 'void' (no-void). This was introduced by the latest commit (3bdb86c), which now returns a promise from disconnect(...); the void operator added to the floating call is disallowed by the no-void rule.

Fix: dropped the void operator — disconnect({stashedCredentials, stashedSession}); — matching the existing floating call to the same function at src/components/AccountSwitcher.tsx:190, which already passes CI.

Note: I couldn't run ESLint locally in this environment, so I'm relying on the re-triggered CI ESLint check to confirm. Every other check (typecheck, all 8 test jobs, knip, Storybook, perf tests, checklist) was already green.

@NicolasBonet
NicolasBonet marked this pull request as ready for review July 10, 2026 15:23
@NicolasBonet
NicolasBonet requested a review from a team as a code owner July 10, 2026 15:23
@melvin-bot
melvin-bot Bot requested a review from ikevin127 July 10, 2026 15:23
@melvin-bot

melvin-bot Bot commented Jul 10, 2026

Copy link
Copy Markdown

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

@melvin-bot
melvin-bot Bot requested review from JmillsExpensify and removed request for a team July 10, 2026 15:23
MelvinBot and others added 3 commits July 10, 2026 11:24
…hen copiloting into an agent

Co-authored-by: Nicolás Bonet <NicolasBonet@users.noreply.github.com>
Co-authored-by: Nicolás Bonet <NicolasBonet@users.noreply.github.com>
Co-authored-by: Nicolás Bonet <NicolasBonet@users.noreply.github.com>
@NicolasBonet
NicolasBonet force-pushed the claude-hideSecurityOptionsWhenCopilotingIntoAgent branch from 1fd870b to e62cea5 Compare July 10, 2026 15:25
@NicolasBonet
NicolasBonet requested a review from a team as a code owner July 10, 2026 15:25
@melvin-bot
melvin-bot Bot requested review from NicolasBonet and truph01 and removed request for a team July 10, 2026 15:25
@melvin-bot

melvin-bot Bot commented Jul 10, 2026

Copy link
Copy Markdown

@truph01 @NicolasBonet One of you needs to 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]

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1fd870b673

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

… flushes

Co-authored-by: Nicolás Bonet <NicolasBonet@users.noreply.github.com>
@MelvinBot

Copy link
Copy Markdown
Contributor Author

🤖 Re-checked the PR — nothing is currently failing, so there's no fix to push.

  • The earlier ESLint check failure (no-void on src/DelegateAccessHandler.tsx) was already fixed and pushed in my previous update.
  • A newer commit (1535097 — "Delete agent within copilot session, then disconnect after the delete flushes") kicked off a fresh full CI run. Every check on that commit is currently in progress with zero failures — I checked all check-runs on the head SHA and found no failure/cancelled/timed_out conclusions.

There's nothing actionable to fix at the moment. If a check does fail once this run finishes, re-run @MelvinBot and I'll dig into the specific failure.

@ikevin127

ikevin127 commented Jul 10, 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 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 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 and each prop has a /** comment above it */
    • The file is named correctly
    • 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
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • 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 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 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

MacOS: Chrome
Online Offline
fixed.mov
offline.mov

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

🐞 Two bugs in the "copiloting into an agent → Close account → Delete" flow

Tested this flow and hit two separate issues. Both are fixed by the DIFF below.


Bug 1 — Delete fails with a 666 permission error; the agent is never deleted

The copilot session ends (you return to your own account) but the agent still appears under Settings > Agents and can still be copiloted into. The API responds with:

{
    "jsonCode": 666,
    "title": "Cannot complete action",
    "message": "You do not have the permission to do the requested action."
}

Root cause: DELETE_AGENT must be issued by the agent's owner, but the current ordering fires it while the session is still authenticated as the agent. Requests get their auth token at send time via enhanceParameters() → getAuthToken() (mirrors ONYXKEYS.SESSION), and enhanceParameters also appends the delegate param while a copilot session is active. So the delete flushes under the agent's identity → backend sees the agent trying to delete itself → 666. This is the same command EditAgentPage runs successfully; the only difference is the identity it's issued under.

The current commit (Delete agent within copilot session, then disconnect after the delete flushes) regressed this — the earlier Delete agent as owner after ending copilot session, not as the agent ordering was correct. The Delegate.ts comment ("the promise is returned so callers can run follow-up work … once the original session is restored") already describes the intended disconnect-first design; the code just stopped following it.

Bug Video
current.mov

Fix: end the copilot session first (restoring the owner's session + auth token), then delete the agent as the owner. Capture the agent's accountID before disconnecting, and await disconnect() so the request goes out under the owner's token. Also remove the now-unused waitForIdle import from @libs/Network/SequentialQueue. The Delegate.ts change (returning the disconnect promise) is now correct as-used since we await it.


Bug 2 — Confirming the delete while offline hangs silently

Repro: copilot into an agent → turn off the network → tap Close account → Delete. Nothing happens in the UI; the network tab shows a pending DisconnectAsDelegate request that never resolves. Going back online (ReconnectApp, AuthenticatePusher, SearchForTodos all fire) does not un-stick it — DisconnectAsDelegate stays pending and the agent is never deleted.

Root cause: disconnect() uses API.makeRequestWithSideEffects (a side-effect request), which is not persisted to the SequentialQueue, so offline it's never queued/retried and await disconnect() never resolves — the whole flow stalls before deleteAgent() is ever reached.

Fix: this flow fundamentally requires a network round-trip, so guard on isOffline and show the standard offline modal (same pattern as DomainMembersPage) instead of starting the flow.


Combined diff (src/pages/settings/Security/SecuritySettingsPage.tsx)

// imports
import useNetwork from '@hooks/useNetwork';
// remove: import {waitForIdle} from '@libs/Network/SequentialQueue';

// inside the component
const {isOffline} = useNetwork();

// close-account action, copilot branch:
if (isCopilotingIntoAgent) {
    // Deleting the agent ends the copilot session via DisconnectAsDelegate, which is a network
    // side-effect request that can't be queued offline (it never resolves, leaving the flow stuck).
    // So require a connection before starting the flow.
    if (isOffline) {
        showConfirmModal({
            title: translate('common.youAppearToBeOffline'),
            prompt: translate('common.thisFeatureRequiresInternet'),
            confirmText: translate('common.buttonConfirm'),
            shouldShowCancelButton: false,
        });
        return;
    }
    const result = await showConfirmModal({
        title: translate('editAgentPage.deleteAgentTitle'),
        prompt: translate('editAgentPage.deleteAgentMessage'),
        confirmText: translate('common.delete'),
        cancelText: translate('common.cancel'),
        danger: true,
    });
    if (result.action !== ModalActions.CONFIRM) {
        return;
    }
    // The DeleteAgent command must be issued by the agent's owner, but while copiloting the session is
    // authenticated as the agent itself (deleting as the agent fails with a 666 permission error). So end
    // the copilot session first (which restores the owner's session and auth token) and only then delete
    // the agent, now that we're acting as the owner.
    const agentAccountID = session?.accountID ?? CONST.DEFAULT_NUMBER_ID;
    await disconnect({stashedCredentials, stashedSession});
    deleteAgent(agentAccountID, undefined, undefined, false);
    return;
}

Remember to add isOffline to the useMemo dependency array for the menu items.

I verified both fixes locally (typecheck passes): disconnect-first deletes the agent successfully as the owner, and the offline guard surfaces a clear "You appear to be offline" modal instead of hanging.


Suggested tests to add

No tests ship with this PR, and the two bugs above are exactly the kind of thing a review can't catch by eye — the failure lives in ordering and offline transport, not in the visible UI. Some coverage worth adding:

  1. Ordering / identity (guards Bug 1): unit test the copilot close-account branch asserting disconnect() is called before deleteAgent(), and that deleteAgent receives the agent's accountID captured pre-disconnect. Why: this is the whole fix — a future refactor could silently flip the order back (as happened here) and reintroduce the 666. A test pins the invariant that the delete runs as the owner.
  2. Offline guard (guards Bug 2): render the page with isOffline = true, trigger the action, and assert the "You appear to be offline" modal shows and neither disconnect() nor deleteAgent() is called. Why: prevents anyone from later "simplifying" the guard away and re-stranding the flow on a DisconnectAsDelegate that can't resolve.
  3. Menu-item gating (guards the core PR change): with isCopilotingIntoAgent = true, assert Device management and Merge accounts are absent and Close account is present; with it false, assert all three render and Close account navigates to SETTINGS_CLOSE. Why: this is the primary behavior of the PR and the most likely thing to regress when the security menu is edited later.
  4. Cancel path: confirm modal → Cancel resolves to a no-op (no disconnect/deleteAgent). Why: a destructive action must be safely abortable; cheap to assert and easy to break.

Note on the offline modal + PR description

The blocking modal is needed specifically because of DisconnectAsDelegate: unlike DELETE_AGENT (a normal API.write() that the SequentialQueue persists and flushes on reconnect), disconnect() is a makeRequestWithSideEffects call that bypasses the queue — it's fire-once, never persisted, never retried. So the usual "queue it and let it run when back online" behavior doesn't apply, and the flow genuinely can't complete offline. That's why we block up front instead of optimistically queuing.

Because of this, the offline behavior here differs from online and the PR's Offline tests section shouldn't just say "Same as tests." It should call out that, when copiloting into an agent, tapping Close account while offline surfaces the offline modal and does not delete the agent or end the copilot session (that requires a connection) — so QA verifies the guard rather than the delete.

cc @NicolasBonet MelvinBot will need your nudge to apply the fixes I mentioned in this comment, due to permission issues.

NicolasBonet and others added 2 commits July 10, 2026 18:46
…state

DeleteAgent must be issued by the agent's owner (the backend derives the
caller from the auth token and rejects the agent deleting itself), so end
the copilot session first and only delete once disconnect() confirms the
owner session was restored. Since DisconnectAsDelegate is a side-effect
request that can't be queued offline, block the flow with the standard
offline modal when there's no connection. Also pass the agent login and
policies to deleteAgent so policy employeeList rows are cleaned up like
they are when deleting from the Edit Agent page.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@NicolasBonet

Copy link
Copy Markdown
Contributor

Thanks @ikevin127 — confirmed both bugs and pushed fixes in a729088. I verified the root causes independently rather than applying the diff as-is:

  • Bug 1 (666 on delete): Confirmed server-side — DeleteAgent derives the caller from the auth token and requires it to be the agent's owner, so issuing it while authenticated as the agent can never succeed. Reordered to disconnect first, then delete as the owner (agent accountID captured before disconnecting). Removed the now-unused waitForIdle import.
  • Bug 2 (offline hang): Confirmed — DisconnectAsDelegate is a makeRequestWithSideEffects call that isn't persisted to the SequentialQueue, so it can't be queued/retried offline. Added the standard offline modal guard (same pattern as WorkspaceMembersPage) before starting the flow, with isOffline added to the memo deps.

I also addressed the two Codex findings on top of your fixes:

  • disconnect() now resolves true/false instead of swallowing failures, and the page only calls deleteAgent() when the disconnect actually restored the owner's session — otherwise a failed disconnect would have queued the delete under the agent's token and hit the 666 again.
  • The copilot delete now passes the agent's login and the policy collection to deleteAgent() so policy employeeList rows are cleaned up the same way as deleting from the Edit Agent page (the backend DeleteAgent doesn't push policy Onyx updates).

Also updated the PR's Offline tests section to describe the offline-modal behavior instead of "Same as tests."

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

🟢 LGTM - All issues were addressed and tests well

…tionsWhenCopilotingIntoAgent

Co-authored-by: Nicolás Bonet <NicolasBonet@users.noreply.github.com>
@MelvinBot

Copy link
Copy Markdown
Contributor Author

🤖 Fixed by merging main.

The failing ESLint check was not caused by this PR — it flagged 4 files this PR never touches (ApproveActionButton.tsx, PayActionButton.tsx, useReportPreviewActionDecision.ts, useReportTransactionViolations.ts) for the rulesdir/no-useOnyx-dependencies-arg rule. This PR only changes Agent.ts, Delegate.ts, and SecuritySettingsPage.tsx.

main was temporarily red from those same violations and was fixed in #95861 ("Fix main ESLint failure by updating seatbelt baseline for ReportPreview refactor", merged 2026-07-10 23:25 UTC) by adding the four entries to config/eslint/eslint.seatbelt.tsv. Our failing lint run kicked off at 22:56 UTC — before that fix landed, so the branch was linting against the stale baseline.

I merged the latest main into this branch (via git merge, no rebase), which brings in the updated seatbelt baseline. ESLint should now pass.

Evidence

@MelvinBot

Copy link
Copy Markdown
Contributor Author

⚠️ Something went wrong. This may be a transient issue — try again. If it persists, check status.anthropic.com.

Run details

@NicolasBonet

Copy link
Copy Markdown
Contributor

@MelvinBot fix eslint

@MelvinBot

Copy link
Copy Markdown
Contributor Author

⚠️ Something went wrong. This may be a transient issue — try again. If it persists, check status.anthropic.com.

Run details

@NicolasBonet

Copy link
Copy Markdown
Contributor

@MelvinBot fix eslint

@MelvinBot

Copy link
Copy Markdown
Contributor Author

⚠️ Something went wrong. This may be a transient issue — try again. If it persists, check status.anthropic.com.

Run details

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

LGTM

@truph01

truph01 commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

@NicolasBonet Could you unassign me from this PR?

@NicolasBonet
NicolasBonet removed the request for review from truph01 July 13, 2026 14:29
@NicolasBonet

Copy link
Copy Markdown
Contributor

@MelvinBot please address the conflicts with main

@MelvinBot

Copy link
Copy Markdown
Contributor Author

⚠️ Something went wrong. This may be a transient issue — try again. If it persists, check status.anthropic.com.

Run details

…Agent

# Conflicts:
#	src/libs/actions/Delegate.ts
@puneetlath
puneetlath merged commit daad72b into main Jul 13, 2026
43 checks passed
@puneetlath
puneetlath deleted the claude-hideSecurityOptionsWhenCopilotingIntoAgent branch July 13, 2026 17:05
@github-actions

Copy link
Copy Markdown
Contributor

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

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/puneetlath in version: 9.4.34-0 🚀

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

@MelvinBot

Copy link
Copy Markdown
Contributor Author

🤖 Help site review complete — docs update required.

This PR changes user-facing behavior on the Security page when Copiloting into an agent (hides Device management and Merge accounts, and repurposes Close account to delete the agent and end the Copilot session). That behavior is documented in the Create and Use Agents article, so I opened a draft docs PR to reflect it.

Draft docs PR: #96050

What it updates:

  • How to delete an agent — adds the new path to delete an agent from Account > Security > Close account while Copiloting (with the Delete agent? confirmation), noting it also ends the Copilot session and requires an internet connection.
  • FAQ — adds "Why does the Security page look different when I Copilot into an agent?" covering the hidden Device management / Merge accounts options and the repurposed Close account action.

All UI labels were verified against src/languages/en.ts and this PR's diff, and the article follows the HelpDot naming and authoring guidelines.

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

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/roryabraham in version: 9.4.34-14 🚀

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

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/roryabraham in version: 9.4.34-14 🚀

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

Bundle Size Analysis (Sentry):

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.

7 participants