diff --git a/src/Expensify.tsx b/src/Expensify.tsx index f822862ec434..5681be838ca8 100644 --- a/src/Expensify.tsx +++ b/src/Expensify.tsx @@ -183,12 +183,12 @@ function Expensify({ // If the app is opened from a deep link, get the reportID (if exists) from the deep link and navigate to the chat report Linking.getInitialURL().then((url) => { setInitialUrl(url); - Report.openReportFromDeepLink(url ?? '', isAuthenticated); + Report.openReportFromDeepLink(url ?? ''); }); // Open chat report from a deep link (only mobile native) Linking.addEventListener('url', (state) => { - Report.openReportFromDeepLink(state.url, isAuthenticated); + Report.openReportFromDeepLink(state.url); }); return () => { diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index b677b5369b68..5c20536e5234 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -2229,10 +2229,10 @@ function toggleEmojiReaction( addEmojiReaction(originalReportID, reportAction.reportActionID, emoji, skinTone); } -function openReportFromDeepLink(url: string, isAuthenticated: boolean) { +function openReportFromDeepLink(url: string) { const reportID = ReportUtils.getReportIDFromLink(url); - if (reportID && !isAuthenticated) { + if (reportID && !Session.hasAuthToken()) { // Call the OpenReport command to check in the server if it's a public room. If so, we'll open it as an anonymous user openReport(reportID, [], {}, '0', true); diff --git a/src/libs/actions/Session/index.ts b/src/libs/actions/Session/index.ts index 619281ac7ecf..47d5419893f5 100644 --- a/src/libs/actions/Session/index.ts +++ b/src/libs/actions/Session/index.ts @@ -184,6 +184,13 @@ function hasStashedSession(): boolean { return Boolean(stashedSession.authToken && stashedCredentials.autoGeneratedLogin && stashedCredentials.autoGeneratedLogin !== ''); } +/** + * Checks if the user has authToken + */ +function hasAuthToken(): boolean { + return !!session.authToken; +} + function signOutAndRedirectToSignIn(shouldReplaceCurrentScreen?: boolean, shouldStashSession?: boolean) { Log.info('Redirecting to Sign In because signOut() was called'); hideContextMenu(false); @@ -987,6 +994,7 @@ export { toggleTwoFactorAuth, validateTwoFactorAuth, waitForUserSignIn, + hasAuthToken, canAnonymousUserAccessRoute, signInWithSupportAuthToken, isSupportAuthToken,