Skip to content

Commit

Permalink
Merge pull request Expensify#56902 from ijmalik/56165
Browse files Browse the repository at this point in the history
  • Loading branch information
dangrous authored Feb 24, 2025
2 parents 510245a + 01bae5c commit b36e675
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Expensify.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import useDebugShortcut from './hooks/useDebugShortcut';
import useIsAuthenticated from './hooks/useIsAuthenticated';
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 @@ -242,6 +243,16 @@ function Expensify() {
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

0 comments on commit b36e675

Please sign in to comment.