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

[Guided Setup Stage 3] Onboarding message not sent when VBBA selected #50052

Merged
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
27 changes: 12 additions & 15 deletions src/components/AddPaymentMethodMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,22 @@ import type {RefObject} from 'react';
import React, {useEffect, useState} from 'react';
import type {View} from 'react-native';
import type {OnyxEntry} from 'react-native-onyx';
import {withOnyx} from 'react-native-onyx';
import {useOnyx} from 'react-native-onyx';
import useLocalize from '@hooks/useLocalize';
import {completePaymentOnboarding} from '@libs/actions/IOU';
import * as ReportActionsUtils from '@libs/ReportActionsUtils';
import * as ReportUtils from '@libs/ReportUtils';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {AnchorPosition} from '@src/styles';
import type {Report, Session} from '@src/types/onyx';
import type {Report} from '@src/types/onyx';
import type AnchorAlignment from '@src/types/utils/AnchorAlignment';
import * as Expensicons from './Icon/Expensicons';
import type {PaymentMethod} from './KYCWall/types';
import type BaseModalProps from './Modal/types';
import PopoverMenu from './PopoverMenu';

type AddPaymentMethodMenuOnyxProps = {
/** Session info for the currently logged-in user. */
session: OnyxEntry<Session>;
};

type AddPaymentMethodMenuProps = AddPaymentMethodMenuOnyxProps & {
type AddPaymentMethodMenuProps = {
/** Should the component be visible? */
isVisible: boolean;

Expand Down Expand Up @@ -58,11 +54,11 @@ function AddPaymentMethodMenu({
anchorRef,
iouReport,
onItemSelected,
session,
shouldShowPersonalBankAccountOption = false,
}: AddPaymentMethodMenuProps) {
const {translate} = useLocalize();
const [restoreFocusType, setRestoreFocusType] = useState<BaseModalProps['restoreFocusType']>();
const [session] = useOnyx(ONYXKEYS.SESSION);

// Users can choose to pay with business bank account in case of Expense reports or in case of P2P IOU report
// which then starts a bottom up flow and creates a Collect workspace where the payer is an admin and payee is an employee.
Expand All @@ -80,6 +76,7 @@ function AddPaymentMethodMenu({
return;
}

completePaymentOnboarding(CONST.PAYMENT_SELECTED.PBA);
onItemSelected(CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT);
}, [isPersonalOnlyOption, isVisible, onItemSelected]);

Expand Down Expand Up @@ -108,6 +105,7 @@ function AddPaymentMethodMenu({
text: translate('common.personalBankAccount'),
icon: Expensicons.Bank,
onSelected: () => {
completePaymentOnboarding(CONST.PAYMENT_SELECTED.PBA);
onItemSelected(CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT);
},
},
Expand All @@ -118,7 +116,10 @@ function AddPaymentMethodMenu({
{
text: translate('common.businessBankAccount'),
icon: Expensicons.Building,
onSelected: () => onItemSelected(CONST.PAYMENT_METHODS.BUSINESS_BANK_ACCOUNT),
onSelected: () => {
completePaymentOnboarding(CONST.PAYMENT_SELECTED.BBA);
Copy link
Contributor

Choose a reason for hiding this comment

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

The workspace ID of the onboarding task can be -1 and user is navigated to the "Not here" page. #52236 caught this.

onItemSelected(CONST.PAYMENT_METHODS.BUSINESS_BANK_ACCOUNT);
},
},
]
: []),
Expand All @@ -140,8 +141,4 @@ function AddPaymentMethodMenu({

AddPaymentMethodMenu.displayName = 'AddPaymentMethodMenu';

export default withOnyx<AddPaymentMethodMenuProps, AddPaymentMethodMenuOnyxProps>({
session: {
key: ONYXKEYS.SESSION,
},
})(AddPaymentMethodMenu);
export default AddPaymentMethodMenu;
Loading