Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/pages/settings/Security/SecuritySettingsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function SecuritySettingsPage() {
});

const {isAccountLocked, showLockedAccountModal} = useContext(LockedAccountContext);
const {isDelegateAccessRestricted, showDelegateNoAccessModal} = useContext(DelegateNoAccessContext);
const {isActingAsDelegate, isDelegateAccessRestricted, showDelegateNoAccessModal} = useContext(DelegateNoAccessContext);
const delegates = account?.delegatedAccess?.delegates ?? [];
const delegators = account?.delegatedAccess?.delegators ?? [];

Expand Down Expand Up @@ -320,7 +320,7 @@ function SecuritySettingsPage() {
text: translate('delegate.removeCopilot'),
icon: Expensicons.Trashcan,
onPress: () => {
if (isDelegateAccessRestricted) {
if (isActingAsDelegate) {
modalClose(() => showDelegateNoAccessModal());
return;
}
Expand Down Expand Up @@ -453,6 +453,11 @@ function SecuritySettingsPage() {
prompt={translate('delegate.removeCopilotConfirmation')}
danger
onConfirm={() => {
if (isActingAsDelegate) {
setShouldShowRemoveDelegateModal(false);
showDelegateNoAccessModal();
return;
}
Comment on lines +456 to +460

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.

Why do we need this logic? We already prevent the user from clicking the "Remove Copilot" button, so is there any chance this logic could still be triggered?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If the session flips to "acting as delegate" after the modal is already open (e.g., user switches to a delegator account in another tab and returns, or future code opens the modal from some other entry point), this check can be useful. What do you think?

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.

@ShridharGoel why inside the onConfirm though?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@grgia Because if the user somehow views the modal and clicks on confirm, but they are a delegate, then the remove-copilot modal will close and instead the "no-access" one will show.

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.

Do you have a video of this flow on your branch

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Screen.Recording.2025-12-20.at.3.51.12.PM.mov
Screen.Recording.2025-12-20.at.3.49.46.PM.mov

removeDelegate({email: selectedDelegate?.email ?? '', delegatedAccess: account?.delegatedAccess});
setShouldShowRemoveDelegateModal(false);
setSelectedDelegate(undefined);
Expand Down
Loading