From 59547174e001d88ae87b374acdcbad29909801e8 Mon Sep 17 00:00:00 2001 From: "Situ Chandra Shil (via MelvinBot)" Date: Thu, 23 Jul 2026 03:40:26 +0000 Subject: [PATCH 1/3] Refactor Onfido native loader to ActivityIndicator Co-authored-by: Situ Chandra Shil --- src/components/Onfido/index.native.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/components/Onfido/index.native.tsx b/src/components/Onfido/index.native.tsx index 10d785c46644..39fbb3b2650a 100644 --- a/src/components/Onfido/index.native.tsx +++ b/src/components/Onfido/index.native.tsx @@ -1,6 +1,7 @@ -import FullscreenLoadingIndicator from '@components/FullscreenLoadingIndicator'; +import ActivityIndicator from '@components/ActivityIndicator'; import useLocalize from '@hooks/useLocalize'; +import useThemeStyles from '@hooks/useThemeStyles'; import getPlatform from '@libs/getPlatform'; import goToSettings from '@libs/goToSettings'; @@ -20,6 +21,7 @@ const {AppStateTracker} = NativeModules; function Onfido({sdkToken, onUserExit, onSuccess, onError}: OnfidoProps) { const {translate} = useLocalize(); + const styles = useThemeStyles(); useEffect(() => { OnfidoSDK.start({ @@ -108,7 +110,13 @@ function Onfido({sdkToken, onUserExit, onSuccess, onError}: OnfidoProps) { // eslint-disable-next-line react-hooks/exhaustive-deps }, []); - return ; + return ( + + ); } export default Onfido; From 1238fa0cfb0638abd78aecd05ffcca34f51ff91b Mon Sep 17 00:00:00 2001 From: "{\"message\":\"Not Found\",\"documentation_url\":\"https://docs.github.com/rest/issues/comments#get-an-issue-comment\",\"status\":\"404\"} (via MelvinBot)" Date: Mon, 3 Aug 2026 21:49:06 +0000 Subject: [PATCH 2/3] Ignore Onfido SDK callbacks after unmount to guard Back during loading Co-authored-by: {"message":"Not Found","documentation_url":"https://docs.github.com/rest/issues/comments#get-an-issue-comment","status":"404"} <{"message":"Not Found","documentation_url":"https://docs.github.com/rest/issues/comments#get-an-issue-comment","status":"404"}@users.noreply.github.com> --- src/components/Onfido/index.native.tsx | 42 +++++++++++++++++++++----- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/src/components/Onfido/index.native.tsx b/src/components/Onfido/index.native.tsx index 39fbb3b2650a..cd428f18dcfd 100644 --- a/src/components/Onfido/index.native.tsx +++ b/src/components/Onfido/index.native.tsx @@ -24,6 +24,28 @@ function Onfido({sdkToken, onUserExit, onSuccess, onError}: OnfidoProps) { const styles = useThemeStyles(); useEffect(() => { + // Back is exposed while OnfidoSDK.start() is still pending, so a late resolve/reject could navigate or mutate + // wallet/bank-account state after the user has already left. Ignore the callbacks once this component unmounts. + let isActive = true; + const handleSuccess: OnfidoProps['onSuccess'] = (data) => { + if (!isActive) { + return; + } + onSuccess(data); + }; + const handleUserExit: OnfidoProps['onUserExit'] = (isUserInitiated) => { + if (!isActive) { + return; + } + onUserExit(isUserInitiated); + }; + const handleError: OnfidoProps['onError'] = (error) => { + if (!isActive) { + return; + } + onError(error); + }; + OnfidoSDK.start({ sdkToken, theme: OnfidoTheme.AUTOMATIC, @@ -40,7 +62,7 @@ function Onfido({sdkToken, onUserExit, onSuccess, onError}: OnfidoProps) { }, }, }) - .then(onSuccess) + .then(handleSuccess) .catch((error: OnfidoError) => { const errorMessage: string = error.message ?? CONST.ERROR.UNKNOWN_ERROR; const errorType = error.type; @@ -52,12 +74,12 @@ function Onfido({sdkToken, onUserExit, onSuccess, onError}: OnfidoProps) { if (([CONST.ONFIDO.ERROR.USER_CANCELLED, CONST.ONFIDO.ERROR.USER_TAPPED_BACK, CONST.ONFIDO.ERROR.USER_EXITED] as string[]).includes(errorMessage)) { if (getPlatform() === CONST.PLATFORM.ANDROID) { AppStateTracker.getWasAppRelaunchedFromIcon().then((wasAppRelaunchedFromIcon) => { - onUserExit(!wasAppRelaunchedFromIcon); + handleUserExit(!wasAppRelaunchedFromIcon); }); return; } - onUserExit(true); + handleUserExit(true); return; } @@ -83,12 +105,12 @@ function Onfido({sdkToken, onUserExit, onSuccess, onError}: OnfidoProps) { [ { text: translate('common.cancel'), - onPress: () => onUserExit(true), + onPress: () => handleUserExit(true), }, { text: translate('common.settings'), onPress: () => { - onUserExit(); + handleUserExit(); goToSettings(); }, }, @@ -97,15 +119,19 @@ function Onfido({sdkToken, onUserExit, onSuccess, onError}: OnfidoProps) { ); return; } - onError(errorMessage); + handleError(errorMessage); }) .catch(() => { - onError(errorMessage); + handleError(errorMessage); }); } else { - onError(errorMessage); + handleError(errorMessage); } }); + + return () => { + isActive = false; + }; // Onfido should be initialized only once on mount // eslint-disable-next-line react-hooks/exhaustive-deps }, []); From 45f9f21e48c007ef7e19c69f038d7782c7b6ebe9 Mon Sep 17 00:00:00 2001 From: "{\"message\":\"Not Found\",\"documentation_url\":\"https://docs.github.com/rest/issues/comments#get-an-issue-comment\",\"status\":\"404\"} (via MelvinBot)" Date: Mon, 3 Aug 2026 22:15:45 +0000 Subject: [PATCH 3/3] Skip stale iOS permission alert when Onfido component unmounts during pending start Co-authored-by: {"message":"Not Found","documentation_url":"https://docs.github.com/rest/issues/comments#get-an-issue-comment","status":"404"} <{"message":"Not Found","documentation_url":"https://docs.github.com/rest/issues/comments#get-an-issue-comment","status":"404"}@users.noreply.github.com> --- src/components/Onfido/index.native.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/components/Onfido/index.native.tsx b/src/components/Onfido/index.native.tsx index cd428f18dcfd..587a07b9e7c9 100644 --- a/src/components/Onfido/index.native.tsx +++ b/src/components/Onfido/index.native.tsx @@ -86,6 +86,11 @@ function Onfido({sdkToken, onUserExit, onSuccess, onError}: OnfidoProps) { if (!!errorMessage && getPlatform() === CONST.PLATFORM.IOS) { checkMultiple([PERMISSIONS.IOS.MICROPHONE, PERMISSIONS.IOS.CAMERA]) .then((statuses) => { + // The permission check resolves asynchronously, so the user may have already backed out (unmounting this + // component) by the time it settles. Skip the alert to avoid showing a stale permission prompt on the screen they returned to. + if (!isActive) { + return; + } const isMicAllowed = statuses[PERMISSIONS.IOS.MICROPHONE] === RESULTS.GRANTED; const isCameraAllowed = statuses[PERMISSIONS.IOS.CAMERA] === RESULTS.GRANTED; let alertTitle: TranslationPaths | '' = '';