Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resolve Copilot account stuck issue when user is removed by another user #56902

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
13 changes: 12 additions & 1 deletion src/Expensify.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import * as CONFIG from './CONFIG';
import CONST from './CONST';
import useLocalize from './hooks/useLocalize';
import {updateLastRoute} from './libs/actions/App';
import {disconnect} from './libs/actions/Delegate';
import * as EmojiPickerAction from './libs/actions/EmojiPickerAction';
import * as Report from './libs/actions/Report';
import * as User from './libs/actions/User';
Expand Down Expand Up @@ -234,9 +235,19 @@ function Expensify() {
if (!isAuthenticated) {
return;
}
setCrashlyticsUserId(session?.accountID ?? -1);
setCrashlyticsUserId(session?.accountID ?? CONST.DEFAULT_NUMBER_ID);
}, [isAuthenticated, session?.accountID]);

useEffect(() => {
if (!account?.delegatedAccess?.delegate) {
return;
}
if (account?.delegatedAccess?.delegates?.some((d) => d.email === account?.delegatedAccess?.delegate)) {
return;
}
disconnect();
}, [account?.delegatedAccess?.delegates, account?.delegatedAccess?.delegate]);

// Display a blank page until the onyx migration completes
if (!isOnyxMigrated) {
return null;
Expand Down
2 changes: 2 additions & 0 deletions src/libs/actions/Delegate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,13 @@ function disconnect() {
.then((response) => {
if (!response?.authToken || !response?.encryptedAuthToken) {
Log.alert('[Delegate] No auth token returned while disconnecting as a delegate');
restoreDelegateSession(stashedSession);
return;
}

if (!response?.requesterID || !response?.requesterEmail) {
Log.alert('[Delegate] No requester data returned while disconnecting as a delegate');
restoreDelegateSession(stashedSession);
return;
}

Expand Down