Skip to content

Don't allow redirect to Desktop app if copilot is on #60128

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

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
11 changes: 10 additions & 1 deletion src/components/DeeplinkWrapper/index.website.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import {Str} from 'expensify-common';
import {useEffect, useRef, useState} from 'react';
import {useOnyx} from 'react-native-onyx';
import {isMobile} from '@libs/Browser';
import getCurrentUrl from '@libs/Navigation/currentUrl';
import shouldPreventDeeplinkPrompt from '@libs/Navigation/helpers/shouldPreventDeeplinkPrompt';
import Navigation from '@libs/Navigation/Navigation';
import navigationRef from '@libs/Navigation/navigationRef';
import {getSearchParamFromUrl} from '@libs/Url';
import {beginDeepLinkRedirect, beginDeepLinkRedirectAfterTransition} from '@userActions/App';
import {getInternalNewExpensifyPath} from '@userActions/Link';
import {isAnonymousUser} from '@userActions/Session';
import CONFIG from '@src/CONFIG';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type DeeplinkWrapperProps from './types';

Expand Down Expand Up @@ -40,6 +44,9 @@ function DeeplinkWrapper({children, isAuthenticated, autoAuthState, initialUrl}:
const [currentScreen, setCurrentScreen] = useState<string | undefined>();
const [hasShownPrompt, setHasShownPrompt] = useState(false);
const removeListener = useRef<() => void>();
const [isActingAsDelegate] = useOnyx(ONYXKEYS.ACCOUNT, {selector: (account) => !!account?.delegatedAccess?.delegate});
const isActingAsDelegateRef = useRef(isActingAsDelegate);
const delegatorEmailRef = useRef(getSearchParamFromUrl(getCurrentUrl(), 'delegatorEmail'));

useEffect(() => {
// If we've shown the prompt and still have a listener registered,
Expand Down Expand Up @@ -78,7 +85,9 @@ function DeeplinkWrapper({children, isAuthenticated, autoAuthState, initialUrl}:
isConnectionCompleteRoute ||
CONFIG.ENVIRONMENT === CONST.ENVIRONMENT.DEV ||
autoAuthState === CONST.AUTO_AUTH_STATE.NOT_STARTED ||
isAnonymousUser()
isAnonymousUser() ||
!!delegatorEmailRef.current ||
isActingAsDelegateRef.current
) {
return;
}
Expand Down