Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
a3b5ebf
implement kyc wall context
dominictb Jul 24, 2025
f351e73
assign kyc wall ref value
dominictb Jul 24, 2025
bb1b04a
Merge branch 'main' of github.life-white.uk-dominictb:dominictb/epsf-app into c…
dominictb Jul 24, 2025
483674c
use kycWallRef from context API
dominictb Jul 24, 2025
5e7980a
Merge branch 'main' of github.life-white.uk-dominictb:dominictb/epsf-app into c…
dominictb Jul 30, 2025
0124baa
fix lint
dominictb Jul 30, 2025
1182a70
Merge branch 'main' of github.life-white.uk-dominictb:dominictb/epsf-app into c…
dominictb Aug 6, 2025
a371b55
Merge branch 'main' of github.life-white.uk-dominictb:dominictb/epsf-app into c…
dominictb Aug 7, 2025
3cccb90
Merge branch 'main' of github.life-white.uk-dominictb:dominictb/epsf-app into c…
dominictb Aug 18, 2025
82e902e
Merge branch 'main' of github.life-white.uk-dominictb:dominictb/epsf-app into c…
dominictb Sep 3, 2025
c501f56
remove forwarded ref
dominictb Sep 3, 2025
3f6661b
Merge branch 'main' of github.life-white.uk-dominictb:dominictb/epsf-app into c…
dominictb Sep 11, 2025
4de72bb
Merge branch 'main' of github.life-white.uk-dominictb:dominictb/epsf-app into c…
dominictb Sep 15, 2025
7a5268c
Merge branch 'main' of github.life-white.uk-dominictb:dominictb/epsf-app into c…
dominictb Sep 22, 2025
27824aa
Merge branch 'main' of github.life-white.uk-dominictb:dominictb/epsf-app into c…
dominictb Oct 2, 2025
8e1f394
Merge branch 'main' of github.life-white.uk-dominictb:dominictb/epsf-app into c…
dominictb Oct 6, 2025
79a00ee
Merge branch 'main' of github.life-white.uk-dominictb:dominictb/epsf-app into c…
dominictb Oct 13, 2025
ee2dfe9
fix typecheck
dominictb Oct 13, 2025
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
2 changes: 2 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import HTMLEngineProvider from './components/HTMLEngineProvider';
import InitialURLContextProvider from './components/InitialURLContextProvider';
import {InputBlurContextProvider} from './components/InputBlurContext';
import KeyboardProvider from './components/KeyboardProvider';
import KYCWallContextProvider from './components/KYCWall/KYCWallContext';
import {LocaleContextProvider} from './components/LocaleContextProvider';
import NavigationBar from './components/NavigationBar';
import OnyxListItemProvider from './components/OnyxListItemProvider';
Expand Down Expand Up @@ -123,6 +124,7 @@ function App() {
FullScreenLoaderContextProvider,
SidePanelContextProvider,
ExpensifyCardContextProvider,
KYCWallContextProvider,
]}
>
<CustomStatusBarAndBackground />
Expand Down
23 changes: 14 additions & 9 deletions src/components/KYCWall/BaseKYCWall.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable react-compiler/react-compiler */
import React, {useCallback, useEffect, useRef, useState} from 'react';
import React, {useCallback, useEffect, useImperativeHandle, useRef, useState} from 'react';
import {Dimensions} from 'react-native';
import type {EmitterSubscription, View} from 'react-native';
import AddPaymentMethodMenu from '@components/AddPaymentMethodMenu';
Expand All @@ -13,7 +13,6 @@ import Log from '@libs/Log';
import Navigation from '@libs/Navigation/Navigation';
import {hasExpensifyPaymentMethod} from '@libs/PaymentUtils';
import {getBankAccountRoute, isExpenseReport as isExpenseReportReportUtils, isIOUReport} from '@libs/ReportUtils';
import {kycWallRef} from '@userActions/PaymentMethods';
import {createWorkspaceFromIOUPayment} from '@userActions/Policy/Policy';
import {setKYCWallSource} from '@userActions/Wallet';
import CONST from '@src/CONST';
Expand Down Expand Up @@ -47,6 +46,7 @@ function KYCWall({
shouldListenForResize = false,
source,
shouldShowPersonalBankAccountOption = false,
ref,
}: KYCWallProps) {
const [userWallet] = useOnyx(ONYXKEYS.USER_WALLET, {canBeMissing: true});
const [walletTerms] = useOnyx(ONYXKEYS.WALLET_TERMS, {canBeMissing: true});
Expand Down Expand Up @@ -270,20 +270,25 @@ function KYCWall({
useEffect(() => {
let dimensionsSubscription: EmitterSubscription | null = null;

kycWallRef.current = {continueAction};

if (shouldListenForResize) {
dimensionsSubscription = Dimensions.addEventListener('change', setMenuPosition);
}

return () => {
if (shouldListenForResize && dimensionsSubscription) {
dimensionsSubscription.remove();
if (!shouldListenForResize || !dimensionsSubscription) {
return;
}

kycWallRef.current = null;
dimensionsSubscription.remove();
};
}, [chatReportID, setMenuPosition, shouldListenForResize, continueAction]);
}, [chatReportID, setMenuPosition, shouldListenForResize]);

useImperativeHandle(
ref,
() => ({
continueAction,
}),
[continueAction],
);

return (
<>
Expand Down
16 changes: 16 additions & 0 deletions src/components/KYCWall/KYCWallContext.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type {ReactNode, RefObject} from 'react';
import React, {createContext, useRef} from 'react';
import type {KYCWallRef} from './types';

type KYCWallContextType = RefObject<KYCWallRef | null>;

const KYCWallContext = createContext<KYCWallContextType>({current: null});

function KYCWallContextProvider({children}: {children: ReactNode}) {
const kycWallRef = useRef<KYCWallRef>(null);

return <KYCWallContext.Provider value={kycWallRef}>{children}</KYCWallContext.Provider>;
}

export default KYCWallContextProvider;
export {KYCWallContext};
3 changes: 2 additions & 1 deletion src/components/KYCWall/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import React from 'react';
import BaseKYCWall from './BaseKYCWall';
import type {KYCWallProps} from './types';

function KYCWall(props: KYCWallProps) {
function KYCWall({ref, ...props}: KYCWallProps) {
return (
<BaseKYCWall
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
shouldListenForResize
ref={ref}
/>
);
}
Expand Down
11 changes: 9 additions & 2 deletions src/components/KYCWall/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type {RefObject} from 'react';
import type {ForwardedRef, RefObject} from 'react';
import type {GestureResponderEvent, View} from 'react-native';
import type {OnyxEntry} from 'react-native-onyx';
import type {ValueOf} from 'type-fest';
Expand Down Expand Up @@ -74,6 +74,13 @@ type KYCWallProps = {

/** The policy used for payment */
policy?: Policy;

/** Reference to the KYCWall component */
ref: ForwardedRef<KYCWallRef>;
};

type KYCWallRef = {
continueAction?: (params: ContinueActionParams) => void;
};

export type {AnchorPosition, KYCWallProps, PaymentMethod, DomRect, PaymentMethodType, Source, ContinueActionParams};
export type {AnchorPosition, KYCWallRef, KYCWallProps, PaymentMethod, DomRect, PaymentMethodType, Source, ContinueActionParams};
3 changes: 3 additions & 0 deletions src/components/MoneyReportHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ import HoldOrRejectEducationalModal from './HoldOrRejectEducationalModal';
import Icon from './Icon';
import * as Expensicons from './Icon/Expensicons';
import KYCWall from './KYCWall';
import {KYCWallContext} from './KYCWall/KYCWallContext';
import type {PaymentMethod} from './KYCWall/types';
import LoadingBar from './LoadingBar';
import Modal from './Modal';
Expand Down Expand Up @@ -392,6 +393,7 @@ function MoneyReportHeader({
const isAnyTransactionOnHold = hasHeldExpensesReportUtils(moneyRequestReport?.reportID);
const {isDelegateAccessRestricted, showDelegateNoAccessModal} = useContext(DelegateNoAccessContext);
const shouldShowLoadingBar = useLoadingBarVisibility();
const kycWallRef = useContext(KYCWallContext);

const isReportInRHP = route.name === SCREENS.SEARCH.REPORT_RHP;
const shouldDisplaySearchRouter = !isReportInRHP || isSmallScreenWidth;
Expand Down Expand Up @@ -1186,6 +1188,7 @@ function MoneyReportHeader({

const KYCMoreDropdown = (
<KYCWall
ref={kycWallRef}
onSuccessfulKYC={(payment) => confirmPayment(payment)}
enablePaymentsRoute={ROUTES.ENABLE_PAYMENTS}
isDisabled={isOffline}
Expand Down
3 changes: 3 additions & 0 deletions src/components/Search/SearchPageHeader/SearchFiltersBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import ButtonWithDropdownMenu from '@components/ButtonWithDropdownMenu';
import type {DropdownOption} from '@components/ButtonWithDropdownMenu/types';
import * as Expensicons from '@components/Icon/Expensicons';
import KYCWall from '@components/KYCWall';
import {KYCWallContext} from '@components/KYCWall/KYCWallContext';
import type {PaymentMethodType} from '@components/KYCWall/types';
import {LockedAccountContext} from '@components/LockedAccountModalProvider';
import {usePersonalDetails} from '@components/OnyxListItemProvider';
Expand Down Expand Up @@ -90,6 +91,7 @@ function SearchFiltersBar({
const theme = useTheme();
const styles = useThemeStyles();
const {translate, localeCompare} = useLocalize();
const kycWallRef = useContext(KYCWallContext);

const {isOffline} = useNetwork();
const personalDetails = usePersonalDetails();
Expand Down Expand Up @@ -643,6 +645,7 @@ function SearchFiltersBar({
<View style={[shouldShowSelectedDropdown && styles.ph5, styles.mb2, styles.searchFiltersBarContainer]}>
{shouldShowSelectedDropdown ? (
<KYCWall
ref={kycWallRef}
chatReportID={currentSelectedReportID}
enablePaymentsRoute={ROUTES.ENABLE_PAYMENTS}
iouReport={selectedIOUReport}
Expand Down
3 changes: 3 additions & 0 deletions src/components/SettlementButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import ButtonWithDropdownMenu from '@components/ButtonWithDropdownMenu';
import * as Expensicons from '@components/Icon/Expensicons';
import {Bank} from '@components/Icon/Expensicons';
import KYCWall from '@components/KYCWall';
import {KYCWallContext} from '@components/KYCWall/KYCWallContext';
import type {ContinueActionParams, PaymentMethod} from '@components/KYCWall/types';
import {LockedAccountContext} from '@components/LockedAccountModalProvider';
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
Expand Down Expand Up @@ -141,6 +142,7 @@ function SettlementButton({

const isInvoiceReport = (!isEmptyObject(iouReport) && isInvoiceReportUtil(iouReport)) || false;
const {isAccountLocked, showLockedAccountModal} = useContext(LockedAccountContext);
const kycWallRef = useContext(KYCWallContext);
const shouldShowPayWithExpensifyOption = !shouldHidePaymentOptions;
const shouldShowPayElsewhereOption = !shouldHidePaymentOptions && !isInvoiceReport;

Expand Down Expand Up @@ -492,6 +494,7 @@ function SettlementButton({

return (
<KYCWall
ref={kycWallRef}
onSuccessfulKYC={(paymentType) => onPress(paymentType, undefined, undefined)}
enablePaymentsRoute={enablePaymentsRoute}
addDebitCardRoute={addDebitCardRoute}
Expand Down
15 changes: 2 additions & 13 deletions src/libs/actions/PaymentMethods.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import {createRef} from 'react';
import type {RefObject} from 'react';
import type {OnyxEntry, OnyxUpdate} from 'react-native-onyx';
import Onyx from 'react-native-onyx';
import type {ValueOf} from 'type-fest';
import type {ContinueActionParams} from '@components/KYCWall/types';
import type {KYCWallRef} from '@components/KYCWall/types';
import * as API from '@libs/API';
import type {
AddPaymentCardParams,
Expand All @@ -29,19 +28,10 @@ import type PaymentMethod from '@src/types/onyx/PaymentMethod';
import type {OnyxData} from '@src/types/onyx/Request';
import type {FilterMethodPaymentType} from '@src/types/onyx/WalletTransfer';

type KYCWallRef = {
continueAction?: (params: ContinueActionParams) => void;
};

/**
* Sets up a ref to an instance of the KYC Wall component.
*/
const kycWallRef: RefObject<KYCWallRef | null> = createRef<KYCWallRef>();

/**
* When we successfully add a payment method or pass the KYC checks we will continue with our setup action if we have one set.
*/
function continueSetup(fallbackRoute?: Route) {
function continueSetup(kycWallRef: RefObject<KYCWallRef | null>, fallbackRoute?: Route) {
if (!kycWallRef.current?.continueAction) {
Navigation.goBack(fallbackRoute);
return;
Expand Down Expand Up @@ -583,7 +573,6 @@ export {
addPaymentCard,
getPaymentMethods,
makeDefaultPaymentMethod,
kycWallRef,
continueSetup,
addSubscriptionPaymentCard,
clearPaymentCardFormErrorAndSubmit,
Expand Down
8 changes: 5 additions & 3 deletions src/pages/AddPersonalBankAccountPage.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import React, {useCallback, useEffect, useState} from 'react';
import React, {useCallback, useContext, useEffect, useState} from 'react';
import AddPlaidBankAccount from '@components/AddPlaidBankAccount';
import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView';
import ConfirmationPage from '@components/ConfirmationPage';
import FormProvider from '@components/Form/FormProvider';
import InputWrapper from '@components/Form/InputWrapper';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import {KYCWallContext} from '@components/KYCWall/KYCWallContext';
import ScreenWrapper from '@components/ScreenWrapper';
import ScrollView from '@components/ScrollView';
import useLocalize from '@hooks/useLocalize';
Expand All @@ -28,6 +29,7 @@ function AddPersonalBankAccountPage() {
const [plaidData] = useOnyx(ONYXKEYS.PLAID_DATA, {canBeMissing: true});
const shouldShowSuccess = personalBankAccount?.shouldShowSuccess ?? false;
const topmostFullScreenRoute = navigationRef.current?.getRootState()?.routes.findLast((route) => isFullScreenName(route.name));
const kycWallRef = useContext(KYCWallContext);

const goBack = useCallback(() => {
switch (topmostFullScreenRoute?.name) {
Expand Down Expand Up @@ -69,12 +71,12 @@ function AddPersonalBankAccountPage() {
if (exitReportID) {
Navigation.dismissModalWithReport({reportID: exitReportID});
} else if (shouldContinue && onSuccessFallbackRoute) {
continueSetup(onSuccessFallbackRoute);
continueSetup(kycWallRef, onSuccessFallbackRoute);
} else {
goBack();
}
},
[personalBankAccount, goBack],
[personalBankAccount, goBack, kycWallRef],
);

useEffect(() => clearPersonalBankAccount, []);
Expand Down
8 changes: 5 additions & 3 deletions src/pages/EnablePayments/ActivateStep.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from 'react';
import React, {useContext} from 'react';
import type {OnyxEntry} from 'react-native-onyx';
import ConfirmationPage from '@components/ConfirmationPage';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import {KYCWallContext} from '@components/KYCWall/KYCWallContext';
import LottieAnimations from '@components/LottieAnimations';
import useLocalize from '@hooks/useLocalize';
import useOnyx from '@hooks/useOnyx';
Expand All @@ -17,8 +18,9 @@ type ActivateStepProps = {

function ActivateStep({userWallet}: ActivateStepProps) {
const {translate} = useLocalize();
const [walletTerms] = useOnyx(ONYXKEYS.WALLET_TERMS);
const [walletTerms] = useOnyx(ONYXKEYS.WALLET_TERMS, {canBeMissing: true});
const isActivatedWallet = userWallet?.tierName && [CONST.WALLET.TIER_NAME.GOLD, CONST.WALLET.TIER_NAME.PLATINUM].some((name) => name === userWallet.tierName);
const kycWallRef = useContext(KYCWallContext);

const animation = isActivatedWallet ? LottieAnimations.Fireworks : LottieAnimations.ReviewingBankInfo;
let continueButtonText = '';
Expand All @@ -40,7 +42,7 @@ function ActivateStep({userWallet}: ActivateStepProps) {
description={translate(`activateStep.${isActivatedWallet ? 'activated' : 'checkBackLater'}Message`)}
shouldShowButton={isActivatedWallet}
buttonText={continueButtonText}
onButtonPress={() => continueSetup()}
onButtonPress={() => continueSetup(kycWallRef)}
/>
</>
);
Expand Down
6 changes: 4 additions & 2 deletions src/pages/EnablePayments/AddBankAccount/AddBankAccount.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React, {useCallback} from 'react';
import React, {useCallback, useContext} from 'react';
import {View} from 'react-native';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import InteractiveStepSubHeader from '@components/InteractiveStepSubHeader';
import {KYCWallContext} from '@components/KYCWall/KYCWallContext';
import ScreenWrapper from '@components/ScreenWrapper';
import useLocalize from '@hooks/useLocalize';
import useOnyx from '@hooks/useOnyx';
Expand All @@ -26,6 +27,7 @@ function AddBankAccount() {
const [personalBankAccountDraft] = useOnyx(ONYXKEYS.FORMS.PERSONAL_BANK_ACCOUNT_FORM_DRAFT, {canBeMissing: true});
const {translate} = useLocalize();
const styles = useThemeStyles();
const kycWallRef = useContext(KYCWallContext);

const submit = useCallback(() => {
const bankAccounts = plaidData?.bankAccounts ?? [];
Expand Down Expand Up @@ -55,7 +57,7 @@ function AddBankAccount() {
return;
}
if (shouldContinue && onSuccessFallbackRoute) {
continueSetup(onSuccessFallbackRoute);
continueSetup(kycWallRef, onSuccessFallbackRoute);
return;
}
Navigation.goBack(ROUTES.SETTINGS_WALLET);
Expand Down
3 changes: 3 additions & 0 deletions src/pages/Search/SearchSelectedNarrow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {View} from 'react-native';
import ButtonWithDropdownMenu from '@components/ButtonWithDropdownMenu';
import type {DropdownOption} from '@components/ButtonWithDropdownMenu/types';
import KYCWall from '@components/KYCWall';
import {KYCWallContext} from '@components/KYCWall/KYCWallContext';
import type {PaymentMethodType} from '@components/KYCWall/types';
import {LockedAccountContext} from '@components/LockedAccountModalProvider';
import type {SearchHeaderOptionValue} from '@components/Search/SearchPageHeader/SearchPageHeader';
Expand Down Expand Up @@ -34,6 +35,7 @@ function SearchSelectedNarrow({options, itemsLength, currentSelectedPolicyID, cu
const [allPolicies] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {canBeMissing: true});
const [selectedIouReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${currentSelectedReportID}`, {canBeMissing: true});
const {translate, localeCompare} = useLocalize();
const kycWallRef = useContext(KYCWallContext);
const currentPolicy = usePolicy(currentSelectedPolicyID);
const [isUserValidated] = useOnyx(ONYXKEYS.ACCOUNT, {selector: (account) => account?.validated, canBeMissing: true});
const isCurrentSelectedExpenseReport = isExpenseReport(currentSelectedReportID);
Expand All @@ -53,6 +55,7 @@ function SearchSelectedNarrow({options, itemsLength, currentSelectedPolicyID, cu

return (
<KYCWall
ref={kycWallRef}
chatReportID={currentSelectedReportID}
iouReport={selectedIouReport}
enablePaymentsRoute={ROUTES.ENABLE_PAYMENTS}
Expand Down
3 changes: 3 additions & 0 deletions src/pages/home/report/PureReportActionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import Icon from '@components/Icon';
import {Eye} from '@components/Icon/Expensicons';
import InlineSystemMessage from '@components/InlineSystemMessage';
import KYCWall from '@components/KYCWall';
import {KYCWallContext} from '@components/KYCWall/KYCWallContext';
import type {LocaleContextProps} from '@components/LocaleContextProvider';
import OfflineWithFeedback from '@components/OfflineWithFeedback';
import PressableWithSecondaryInteraction from '@components/PressableWithSecondaryInteraction';
Expand Down Expand Up @@ -468,6 +469,7 @@ function PureReportActionItem({
const [moderationDecision, setModerationDecision] = useState<OnyxTypes.DecisionName>(CONST.MODERATION.MODERATOR_DECISION_APPROVED);
const reactionListRef = useContext(ReactionListContext);
const {updateHiddenAttachments} = useContext(AttachmentModalContext);
const kycWallRef = useContext(KYCWallContext);
const composerTextInputRef = useRef<TextInput | HTMLTextAreaElement>(null);
const popoverAnchorRef = useRef<Exclude<ContextMenuAnchor, TextInput>>(null);
const downloadedPreviews = useRef<string[]>([]);
Expand Down Expand Up @@ -1093,6 +1095,7 @@ function PureReportActionItem({
)}
{missingPaymentMethod === 'wallet' && (
<KYCWall
ref={kycWallRef}
onSuccessfulKYC={() => Navigation.navigate(ROUTES.ENABLE_PAYMENTS)}
enablePaymentsRoute={ROUTES.ENABLE_PAYMENTS}
addBankAccountRoute={ROUTES.BANK_ACCOUNT_PERSONAL}
Expand Down
Loading