Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Internal QA]: Update web behaviour of bank connection for card assign #55561

Merged
merged 1 commit into from
Jan 22, 2025
Merged
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, {useCallback, useEffect} from 'react';
import {useOnyx} from 'react-native-onyx';
import BlockingView from '@components/BlockingViews/BlockingView';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import * as Illustrations from '@components/Icon/Illustrations';
Expand All @@ -8,12 +9,12 @@ import TextLink from '@components/TextLink';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import {setAssignCardStepAndData} from '@libs/actions/CompanyCards';
import {getBankName} from '@libs/CardUtils';
import {getBankName, isSelectedFeedExpired} from '@libs/CardUtils';
import Navigation from '@libs/Navigation/Navigation';
import getCurrentUrl from '@navigation/currentUrl';
import {getWorkspaceAccountID} from '@libs/PolicyUtils';
import getCompanyCardBankConnection from '@userActions/getCompanyCardBankConnection';
import CONST from '@src/CONST';
import ROUTES from '@src/ROUTES';
import ONYXKEYS from '@src/ONYXKEYS';
import type {CompanyCardFeed} from '@src/types/onyx';
import openBankConnection from './openBankConnection';

Expand All @@ -31,9 +32,10 @@ function BankConnection({policyID, feed}: BankConnectionStepProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
const bankName = getBankName(feed);
const currentUrl = getCurrentUrl();
const isBankConnectionCompleteRoute = currentUrl.includes(ROUTES.BANK_CONNECTION_COMPLETE);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VickyStash Hmm I am not sure about this change - we basically go back to what we had before, relying on the pusher update to the SHARED_NVP_PRIVATE_DOMAIN_MEMBER but Vicky changed it to use the url - when we complete the connection we should to to the bank-connection-completed route. Why is that not working in this case?

const workspaceAccountID = getWorkspaceAccountID(policyID);
const [cardFeeds] = useOnyx(`${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${workspaceAccountID}`);
const url = getCompanyCardBankConnection(policyID, bankName);
const isFeedExpired = isSelectedFeedExpired(cardFeeds?.settings?.oAuthAccountDetails?.[feed]);

const onOpenBankConnectionFlow = useCallback(() => {
if (!url) {
Expand All @@ -57,7 +59,7 @@ function BankConnection({policyID, feed}: BankConnectionStepProps) {
if (!url) {
return;
}
if (isBankConnectionCompleteRoute) {
if (!isFeedExpired) {
customWindow?.close();
setAssignCardStepAndData({
currentStep: CONST.COMPANY_CARD.STEP.ASSIGNEE,
Expand All @@ -66,7 +68,7 @@ function BankConnection({policyID, feed}: BankConnectionStepProps) {
return;
}
customWindow = openBankConnection(url);
}, [isBankConnectionCompleteRoute, policyID, url]);
}, [isFeedExpired, policyID, url]);

return (
<ScreenWrapper testID={BankConnection.displayName}>
Expand Down
Loading