From d11f7dfcaeddba0b5d30a93134ce9fd6dc82a95e Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Fri, 31 Jan 2025 10:49:14 +0800 Subject: [PATCH 1/3] encode exitTo url --- src/libs/actions/Link.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/Link.ts b/src/libs/actions/Link.ts index cee639f4c4a3..595f510098b0 100644 --- a/src/libs/actions/Link.ts +++ b/src/libs/actions/Link.ts @@ -197,7 +197,7 @@ function openLink(href: string, environmentURL: string, isAttachment = false) { function buildURLWithAuthToken(url: string, shortLivedAuthToken?: string) { const authTokenParam = shortLivedAuthToken ? `shortLivedAuthToken=${shortLivedAuthToken}` : ''; const emailParam = `email=${encodeURIComponent(currentUserEmail)}`; - const exitTo = `exitTo=${url}`; + const exitTo = `exitTo=${encodeURIComponent(url)}`; const accountID = `accountID=${currentUserAccountID}`; const referrer = 'referrer=desktop'; const paramsArray = [accountID, emailParam, authTokenParam, exitTo, referrer]; From b4c292b7e6be3f5642c2a1a669d5432a056c7aee Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Fri, 31 Jan 2025 10:49:33 +0800 Subject: [PATCH 2/3] only set the loading immediately if policyID param exists --- src/pages/ReimbursementAccount/ReimbursementAccountPage.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pages/ReimbursementAccount/ReimbursementAccountPage.tsx b/src/pages/ReimbursementAccount/ReimbursementAccountPage.tsx index 35c89cc72285..c9ad0a142168 100644 --- a/src/pages/ReimbursementAccount/ReimbursementAccountPage.tsx +++ b/src/pages/ReimbursementAccount/ReimbursementAccountPage.tsx @@ -257,7 +257,9 @@ function ReimbursementAccountPage({route, policy, isLoadingPolicy}: Reimbursemen return; } - setReimbursementAccountLoading(true); + if (policyIDParam) { + setReimbursementAccountLoading(true); + } clearReimbursementAccountDraft(); // If the step to open is empty, we want to clear the sub step, so the connect option view is shown to the user From 9f4b167401ec23cab9b892831ec6c963e4b15963 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Thu, 13 Feb 2025 14:47:52 +0800 Subject: [PATCH 3/3] lint --- src/libs/actions/Link.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libs/actions/Link.ts b/src/libs/actions/Link.ts index 595f510098b0..a3236c6efaca 100644 --- a/src/libs/actions/Link.ts +++ b/src/libs/actions/Link.ts @@ -12,7 +12,7 @@ import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import type {Route} from '@src/ROUTES'; import ROUTES from '@src/ROUTES'; -import * as Session from './Session'; +import {canAnonymousUserAccessRoute, isAnonymousUser, signOutAndRedirectToSignIn} from './Session'; let isNetworkOffline = false; Onyx.connect({ @@ -26,7 +26,7 @@ Onyx.connect({ key: ONYXKEYS.SESSION, callback: (value) => { currentUserEmail = value?.email ?? ''; - currentUserAccountID = value?.accountID ?? -1; + currentUserAccountID = value?.accountID ?? CONST.DEFAULT_NUMBER_ID; }, }); @@ -168,7 +168,7 @@ function openLink(href: string, environmentURL: string, isAttachment = false) { // the reportID is extracted from the URL and then opened as an internal link, taking the user straight to the chat in the same tab. if (hasExpensifyOrigin && href.indexOf('newdotreport?reportID=') > -1) { const reportID = href.split('newdotreport?reportID=').pop(); - const reportRoute = ROUTES.REPORT_WITH_ID.getRoute(reportID ?? '-1'); + const reportRoute = ROUTES.REPORT_WITH_ID.getRoute(reportID); Navigation.navigate(reportRoute); return; } @@ -176,8 +176,8 @@ function openLink(href: string, environmentURL: string, isAttachment = false) { // If we are handling a New Expensify link then we will assume this should be opened by the app internally. This ensures that the links are opened internally via react-navigation // instead of in a new tab or with a page refresh (which is the default behavior of an anchor tag) if (internalNewExpensifyPath && hasSameOrigin) { - if (Session.isAnonymousUser() && !Session.canAnonymousUserAccessRoute(internalNewExpensifyPath)) { - Session.signOutAndRedirectToSignIn(); + if (isAnonymousUser() && !canAnonymousUserAccessRoute(internalNewExpensifyPath)) { + signOutAndRedirectToSignIn(); return; } Navigation.navigate(internalNewExpensifyPath as Route);