Skip to content

Commit 6d44afd

Browse files
amyevansOSBotify
authored andcommitted
Merge pull request #87996 from callstack-internal/fix/87757-plaid-redirect-issue
[CP staging] Fix Plaid redirect issue on iOS (cherry picked from commit fca974f) (cherry-picked to staging by AndrewGable)
1 parent 5600b9c commit 6d44afd

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

src/libs/Navigation/helpers/getAdaptedStateFromPath.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,13 @@ const getAdaptedStateFromPath: GetAdaptedStateFromPath = (path, options, shouldR
354354
normalizedPath = '/';
355355
}
356356

357+
// The Plaid OAuth redirect URI for iOS (partners/plaid/oauth_ios) is not a registered route.
358+
// When this URL is processed — either as a deep link or opened in Safari — redirect to home
359+
// to avoid showing NotFound. The native Plaid SDK handles the actual OAuth callback separately.
360+
if (normalizedPath.startsWith('/partners/plaid/oauth_ios')) {
361+
normalizedPath = '/';
362+
}
363+
357364
const state = getStateFromPath(normalizedPath as RoutePath) as PartialState<NavigationState<RootNavigatorParamList>>;
358365
if (shouldReplacePathInNestedState) {
359366
replacePathInNestedState(state, normalizedPath);

src/libs/actions/Link.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,11 @@ function openReportFromDeepLink(
281281
return;
282282
}
283283

284+
// The Plaid OAuth redirect URI is handled by the native Plaid SDK on iOS — skip navigation to avoid showing NotFound
285+
if (route?.includes('partners/plaid/oauth_ios')) {
286+
return;
287+
}
288+
284289
// Navigate to the report after sign-in/sign-up.
285290
// eslint-disable-next-line @typescript-eslint/no-deprecated
286291
InteractionManager.runAfterInteractions(() => {

src/pages/settings/Wallet/PersonalCards/steps/PlaidConnectionStep.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import useNetwork from '@hooks/useNetwork';
1313
import useOnyx from '@hooks/useOnyx';
1414
import useThemeStyles from '@hooks/useThemeStyles';
1515
import {setAddNewPersonalCardStepAndData} from '@libs/actions/PersonalCards';
16+
import getPlaidOAuthReceivedRedirectURI from '@libs/getPlaidOAuthReceivedRedirectURI';
1617
import KeyboardShortcut from '@libs/KeyboardShortcut';
1718
import Log from '@libs/Log';
1819
import type {SkeletonSpanReasonAttributes} from '@libs/telemetry/useSkeletonSpan';
@@ -33,9 +34,10 @@ type PlaidLinkContentProps = {
3334
onError: (error: ErrorEvent | null) => void;
3435
onEvent: (eventName: string) => void;
3536
onExit: () => void;
37+
receivedRedirectURI?: string;
3638
};
3739

38-
function PlaidLinkContent({plaidLinkToken, plaidDataErrorMessage, plaidData, onSuccess, onError, onEvent, onExit}: PlaidLinkContentProps) {
40+
function PlaidLinkContent({plaidLinkToken, plaidDataErrorMessage, plaidData, onSuccess, onError, onEvent, onExit, receivedRedirectURI}: PlaidLinkContentProps) {
3941
const styles = useThemeStyles();
4042

4143
if (plaidLinkToken) {
@@ -46,6 +48,7 @@ function PlaidLinkContent({plaidLinkToken, plaidDataErrorMessage, plaidData, onS
4648
onError={onError}
4749
onEvent={onEvent}
4850
onExit={onExit}
51+
receivedRedirectURI={receivedRedirectURI}
4952
/>
5053
);
5154
}
@@ -202,6 +205,7 @@ function PlaidConnectionStep({feed, onExit}: {feed?: CompanyCardFeedWithDomainID
202205
onError={handlePlaidLinkError}
203206
onEvent={handlePlaidLinkEvent}
204207
onExit={handlePlaidLinkExit}
208+
receivedRedirectURI={getPlaidOAuthReceivedRedirectURI()}
205209
/>
206210
</FullPageOfflineBlockingView>
207211
)}

src/pages/workspace/companyCards/addNew/PlaidConnectionStep.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import useNetwork from '@hooks/useNetwork';
1313
import useOnyx from '@hooks/useOnyx';
1414
import useThemeStyles from '@hooks/useThemeStyles';
1515
import {setAddNewCompanyCardStepAndData, setAssignCardStepAndData} from '@libs/actions/CompanyCards';
16+
import getPlaidOAuthReceivedRedirectURI from '@libs/getPlaidOAuthReceivedRedirectURI';
1617
import KeyboardShortcut from '@libs/KeyboardShortcut';
1718
import Log from '@libs/Log';
1819
import {getDomainNameForPolicy} from '@libs/PolicyUtils';
@@ -121,6 +122,7 @@ function PlaidConnectionStep({feed, policyID, onExit, title}: PlaidConnectionSte
121122
return (
122123
<PlaidLink
123124
token={plaidLinkToken}
125+
receivedRedirectURI={getPlaidOAuthReceivedRedirectURI()}
124126
onSuccess={({publicToken, metadata}) => {
125127
// on success we need to move to bank connection screen with token, bank name = plaid
126128
Log.info('[PlaidLink] Success!');

0 commit comments

Comments
 (0)