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

Consolidate options on settlement "Pay" button #37174

Merged
merged 95 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
a534dd8
consolidated settlement pay button
brandonhenry Feb 24, 2024
f9cdaf1
Merge remote-tracking branch 'upstream/main' into 36301-clean-up-paym…
brandonhenry Feb 29, 2024
686227e
Merge remote-tracking branch 'upstream/main' into 36301-clean-up-paym…
brandonhenry Feb 29, 2024
3808611
Merge remote-tracking branch 'upstream/main' into 36301-clean-up-paym…
brandonhenry Mar 1, 2024
08a1fc1
removal of extra payment window and re-organized to properly use paym…
brandonhenry Mar 7, 2024
9b32a12
updated with main
brandonhenry Mar 8, 2024
c825bc0
Update SettlementButton to match main
brandonhenry Mar 8, 2024
c3d9865
Update SettlementButton match main even more
brandonhenry Mar 8, 2024
f3336e0
updated with main
brandonhenry Mar 8, 2024
d468376
removed default case
brandonhenry Mar 9, 2024
1aa89d3
Merge remote-tracking branch 'upstream/main' into 36301-clean-up-paym…
brandonhenry Mar 11, 2024
20fe845
Merge remote-tracking branch 'upstream/main' into 36301-clean-up-paym…
brandonhenry Mar 12, 2024
052ef03
Merge remote-tracking branch 'upstream/main' into 36301-clean-up-paym…
brandonhenry Mar 12, 2024
004d3a5
Merge remote-tracking branch 'upstream/main' into 36301-clean-up-paym…
brandonhenry Mar 13, 2024
07a73b0
Merge remote-tracking branch 'upstream/main' into 36301-clean-up-paym…
brandonhenry Mar 17, 2024
012b213
Merge remote-tracking branch 'upstream/main' into 36301-clean-up-paym…
brandonhenry Mar 27, 2024
f77346d
Merge remote-tracking branch 'upstream/main' into 36301-clean-up-paym…
brandonhenry Mar 29, 2024
4172c34
Merge remote-tracking branch 'upstream/main' into 36301-clean-up-paym…
brandonhenry Apr 4, 2024
21bab68
Added PaymentMethodType as an option for the dropdown to match old style
brandonhenry Apr 4, 2024
a3ae2f8
added translations to fix jest tests
brandonhenry Apr 4, 2024
6619e11
Removed unnecessary components
brandonhenry Apr 4, 2024
0e3bd69
Prettier run
brandonhenry Apr 4, 2024
4e93753
Removed fragment and updated initial button options
brandonhenry Apr 8, 2024
77fcc09
Merge remote-tracking branch 'upstream/main' into 36301-clean-up-paym…
brandonhenry Apr 8, 2024
c4f7b85
Removed react import
brandonhenry Apr 8, 2024
55e3e28
Update BaseKYCWall.tsx
brandonhenry Apr 8, 2024
114aa85
Update BaseKYCWall.tsx
brandonhenry Apr 8, 2024
4a17c6a
Update BaseKYCWall.tsx
brandonhenry Apr 8, 2024
d17a05c
Merge remote-tracking branch 'upstream/main' into 36301-clean-up-paym…
brandonhenry Apr 9, 2024
da3c50e
removed expensify option and fixed breakage
brandonhenry Apr 9, 2024
11f87f2
Update SettlementButton.tsx
brandonhenry Apr 9, 2024
a72034d
swap changes around
brandonhenry Apr 11, 2024
e8c4da0
Merge remote-tracking branch 'upstream/main' into 36301-clean-up-paym…
brandonhenry Apr 12, 2024
b54580b
revert and check if payment added
brandonhenry Apr 17, 2024
da65b89
Merge remote-tracking branch 'upstream/main' into 36301-clean-up-paym…
brandonhenry Apr 17, 2024
7e8a0cd
adding back in shouldshowpaywithexpensifyoptions
brandonhenry Apr 17, 2024
0ced26e
eslint fix
brandonhenry Apr 17, 2024
80e6401
updated per feedback
brandonhenry Apr 25, 2024
edb64a7
updated per feedback
brandonhenry Apr 25, 2024
4c54a1a
prettier
brandonhenry Apr 25, 2024
06c9b27
Merge remote-tracking branch 'upstream/main' into 36301-clean-up-paym…
brandonhenry Apr 25, 2024
1d74e6c
Merge remote-tracking branch 'upstream/main' into 36301-clean-up-paym…
brandonhenry Apr 26, 2024
659303f
Merge remote-tracking branch 'upstream/main' into 36301-clean-up-paym…
brandonhenry Apr 28, 2024
82802e1
Merge remote-tracking branch 'upstream/main' into 36301-clean-up-paym…
brandonhenry May 8, 2024
224c4d5
Update BaseKYCWall.tsx
brandonhenry May 8, 2024
f5d40fa
code review updates
brandonhenry May 10, 2024
cf08526
fixed linter issues
brandonhenry May 10, 2024
4402edf
Merge remote-tracking branch 'upstream/main' into 36301-clean-up-paym…
brandonhenry May 13, 2024
78b851e
Update SettlementButton.tsx
brandonhenry May 13, 2024
77b2ad5
order matters
brandonhenry May 13, 2024
9c63799
add in elsewhere
brandonhenry May 13, 2024
482a1df
Update SettlementButton.tsx
brandonhenry May 13, 2024
d599fbd
Merge remote-tracking branch 'upstream/main' into 36301-clean-up-paym…
brandonhenry May 31, 2024
79e7410
Update BaseKYCWall.tsx
brandonhenry Jun 1, 2024
df01e1c
Altered elsewhere needing KYC
brandonhenry Jun 2, 2024
9f9f8c1
Merge remote-tracking branch 'upstream/main' into 36301-clean-up-paym…
brandonhenry Jun 4, 2024
a6be971
Update SettlementButton.tsx
brandonhenry Jun 4, 2024
1788ebf
Merge remote-tracking branch 'upstream/main' into 36301-clean-up-paym…
brandonhenry Jun 7, 2024
17a8654
Revert settlementbutton changes to match prod and pass
brandonhenry Jun 7, 2024
3031ef8
Removed newlines
brandonhenry Jun 7, 2024
c069009
Merge remote-tracking branch 'upstream/main' into 36301-clean-up-paym…
brandonhenry Jun 9, 2024
1d99017
Merge remote-tracking branch 'upstream/main' into 36301-clean-up-paym…
brandonhenry Jun 11, 2024
cd5f9c4
Merge remote-tracking branch 'upstream/main' into 36301-clean-up-paym…
brandonhenry Jun 19, 2024
8fda778
Merge remote-tracking branch 'upstream/main' into 36301-clean-up-paym…
brandonhenry Jun 24, 2024
1f708a2
Merge remote-tracking branch 'upstream/main' into 36301-clean-up-paym…
brandonhenry Jun 25, 2024
cbe89b4
match staging
brandonhenry Jun 25, 2024
17d0f5b
Merge remote-tracking branch 'upstream/main' into 36301-clean-up-paym…
brandonhenry Jun 25, 2024
f98bfb0
Merge branch 'main' into 36301-clean-up-payment-options
brandonhenry Jun 27, 2024
1676e3a
Merge remote-tracking branch 'upstream/main' into 36301-clean-up-paym…
brandonhenry Jul 3, 2024
5e90b4a
Fixed missing option showing
brandonhenry Jul 3, 2024
ae8a198
prettier
brandonhenry Jul 3, 2024
2e53e25
Merge remote-tracking branch 'upstream/main' into 36301-clean-up-paym…
brandonhenry Jul 3, 2024
edb1fd5
Merge remote-tracking branch 'upstream/main' into 36301-clean-up-paym…
brandonhenry Jul 4, 2024
59f3bab
prettier
brandonhenry Jul 4, 2024
228108f
Merge branch 'main' into 36301-clean-up-payment-options
brandonhenry Jul 5, 2024
4925d1d
removing should should option
brandonhenry Jul 17, 2024
db4f727
Merge remote-tracking branch 'upstream/main' into 36301-clean-up-paym…
brandonhenry Jul 18, 2024
68caa23
Update sanitizeStringForJSONParse.ts
brandonhenry Jul 18, 2024
3b374ad
Update DateUtilsTest.ts
brandonhenry Jul 18, 2024
8b4aa91
prettier
brandonhenry Jul 18, 2024
4d30989
Merge remote-tracking branch 'upstream/main' into 36301-clean-up-paym…
brandonhenry Jul 22, 2024
eaf6019
Merge remote-tracking branch 'upstream/main' into 36301-clean-up-paym…
brandonhenry Jul 26, 2024
4ec42c3
Merge remote-tracking branch 'upstream/main' into 36301-clean-up-paym…
brandonhenry Jul 28, 2024
41aeb61
Merge remote-tracking branch 'upstream/main' into 36301-clean-up-paym…
brandonhenry Jul 29, 2024
9bc4ae1
updated settlement button
brandonhenry Jul 29, 2024
cecd6ff
Merge remote-tracking branch 'upstream/main' into 36301-clean-up-paym…
brandonhenry Aug 5, 2024
6ecf1d4
Merge remote-tracking branch 'upstream/main' into 36301-clean-up-paym…
brandonhenry Aug 18, 2024
a54ba60
Merge remote-tracking branch 'upstream/main' into 36301-clean-up-paym…
brandonhenry Aug 21, 2024
4a4519b
Update SettlementButton.tsx
brandonhenry Aug 21, 2024
77a6688
Update SettlementButton.tsx
brandonhenry Aug 21, 2024
d3cf95e
final fix
brandonhenry Aug 23, 2024
dd375ce
Merge remote-tracking branch 'upstream/main' into 36301-clean-up-paym…
brandonhenry Aug 23, 2024
1df72c8
Merge remote-tracking branch 'upstream/main' into 36301-clean-up-paym…
brandonhenry Aug 26, 2024
2f9c1d6
Added back in personalbankaccount set
brandonhenry Aug 26, 2024
969b5c2
Merge remote-tracking branch 'upstream/main' into 36301-clean-up-paym…
brandonhenry Aug 26, 2024
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: 1 addition & 1 deletion src/components/ButtonWithDropdownMenu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function ButtonWithDropdownMenu<IValueType>({
if ('measureInWindow' in dropdownAnchor.current) {
dropdownAnchor.current.measureInWindow((x, y, w, h) => {
setPopoverAnchorPosition({
horizontal: x + w,
horizontal: x + w + h,
vertical:
anchorAlignment.vertical === CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.TOP
? y + h + CONST.MODAL.POPOVER_MENU_PADDING // if vertical anchorAlignment is TOP, menu will open below the button and we need to add the height of button and padding
Expand Down
3 changes: 2 additions & 1 deletion src/components/ButtonWithDropdownMenu/types.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import type {RefObject} from 'react';
import type {GestureResponderEvent, StyleProp, View, ViewStyle} from 'react-native';
import type {ValueOf} from 'type-fest';
import type {PaymentMethodType} from '@components/KYCWall/types';
import type CONST from '@src/CONST';
import type AnchorAlignment from '@src/types/utils/AnchorAlignment';
import type DeepValueOf from '@src/types/utils/DeepValueOf';
import type IconAsset from '@src/types/utils/IconAsset';

type PaymentType = DeepValueOf<typeof CONST.IOU.PAYMENT_TYPE | typeof CONST.IOU.REPORT_ACTION_TYPE>;
type PaymentType = DeepValueOf<typeof CONST.IOU.PAYMENT_TYPE | typeof CONST.IOU.REPORT_ACTION_TYPE | PaymentMethodType>;

type WorkspaceMemberBulkActionType = DeepValueOf<typeof CONST.POLICY.MEMBERS_BULK_ACTION_TYPES>;

Expand Down
129 changes: 17 additions & 112 deletions src/components/KYCWall/BaseKYCWall.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import React, {useCallback, useEffect, useRef, useState} from 'react';
import {Dimensions} from 'react-native';
import type {EmitterSubscription, GestureResponderEvent, View} from 'react-native';
import React, {useCallback, useRef} from 'react';
import type {GestureResponderEvent, View} from 'react-native';
import {withOnyx} from 'react-native-onyx';
import type {OnyxEntry} from 'react-native-onyx';
import AddPaymentMethodMenu from '@components/AddPaymentMethodMenu';
import * as BankAccounts from '@libs/actions/BankAccounts';
import getClickedTargetLocation from '@libs/getClickedTargetLocation';
import Log from '@libs/Log';
import Navigation from '@libs/Navigation/Navigation';
import * as PaymentUtils from '@libs/PaymentUtils';
import * as ReportUtils from '@libs/ReportUtils';
import * as PaymentMethods from '@userActions/PaymentMethods';
import * as Policy from '@userActions/Policy/Policy';
import * as Wallet from '@userActions/Wallet';
import CONST from '@src/CONST';
Expand All @@ -19,10 +15,7 @@ import ROUTES from '@src/ROUTES';
import type {BankAccountList, FundList, ReimbursementAccount, UserWallet, WalletTerms} from '@src/types/onyx';
import type {PaymentMethodType} from '@src/types/onyx/OriginalMessage';
import viewRef from '@src/types/utils/viewRef';
import type {AnchorPosition, DomRect, KYCWallProps, PaymentMethod} from './types';

// This sets the Horizontal anchor position offset for POPOVER MENU.
const POPOVER_MENU_ANCHOR_POSITION_HORIZONTAL_OFFSET = 20;
import type {KYCWallProps, PaymentMethod} from './types';

type BaseKYCWallOnyxProps = {
/** The user's wallet */
Expand All @@ -49,10 +42,6 @@ type BaseKYCWallProps = KYCWallProps & BaseKYCWallOnyxProps;
function KYCWall({
addBankAccountRoute,
addDebitCardRoute,
anchorAlignment = {
horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.LEFT,
vertical: CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.BOTTOM,
},
bankAccountList = {},
chatReportID = '',
children,
Expand All @@ -63,60 +52,13 @@ function KYCWall({
onSuccessfulKYC,
reimbursementAccount,
shouldIncludeDebitCard = true,
shouldListenForResize = false,
source,
userWallet,
walletTerms,
shouldShowPersonalBankAccountOption = false,
}: BaseKYCWallProps) {
const anchorRef = useRef<HTMLDivElement | View>(null);
const transferBalanceButtonRef = useRef<HTMLDivElement | View | null>(null);

const [shouldShowAddPaymentMenu, setShouldShowAddPaymentMenu] = useState(false);

const [anchorPosition, setAnchorPosition] = useState({
anchorPositionVertical: 0,
anchorPositionHorizontal: 0,
});

const getAnchorPosition = useCallback(
(domRect: DomRect): AnchorPosition => {
if (anchorAlignment.vertical === CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.TOP) {
return {
anchorPositionVertical: domRect.top + domRect.height + CONST.MODAL.POPOVER_MENU_PADDING,
anchorPositionHorizontal: domRect.left + POPOVER_MENU_ANCHOR_POSITION_HORIZONTAL_OFFSET,
};
}

return {
anchorPositionVertical: domRect.top - CONST.MODAL.POPOVER_MENU_PADDING,
anchorPositionHorizontal: domRect.left,
};
},
[anchorAlignment.vertical],
);

/**
* Set position of the transfer payment menu
*/
const setPositionAddPaymentMenu = ({anchorPositionVertical, anchorPositionHorizontal}: AnchorPosition) => {
setAnchorPosition({
anchorPositionVertical,
anchorPositionHorizontal,
});
};

const setMenuPosition = useCallback(() => {
if (!transferBalanceButtonRef.current) {
return;
}

const buttonPosition = getClickedTargetLocation(transferBalanceButtonRef.current as HTMLDivElement);
const position = getAnchorPosition(buttonPosition);

setPositionAddPaymentMenu(position);
}, [getAnchorPosition]);

const selectPaymentMethod = useCallback(
(paymentMethod: PaymentMethod) => {
onSelectPaymentMethod(paymentMethod);
Expand Down Expand Up @@ -159,11 +101,6 @@ function KYCWall({
*/
Wallet.setKYCWallSource(source, chatReportID);

if (shouldShowAddPaymentMenu) {
setShouldShowAddPaymentMenu(false);
return;
}

// Use event target as fallback if anchorRef is null for safety
const targetElement = anchorRef.current ?? (event?.currentTarget as HTMLDivElement);

Expand All @@ -184,11 +121,19 @@ function KYCWall({
return;
}

const clickedElementLocation = getClickedTargetLocation(targetElement as HTMLDivElement);
const position = getAnchorPosition(clickedElementLocation);

setPositionAddPaymentMenu(position);
setShouldShowAddPaymentMenu(true);
switch (iouPaymentType) {
case CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT:
selectPaymentMethod(CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT);
break;
brandonhenry marked this conversation as resolved.
Show resolved Hide resolved
case CONST.PAYMENT_METHODS.DEBIT_CARD:
selectPaymentMethod(CONST.PAYMENT_METHODS.DEBIT_CARD);
break;
case CONST.PAYMENT_METHODS.BUSINESS_BANK_ACCOUNT:
selectPaymentMethod(CONST.PAYMENT_METHODS.BUSINESS_BANK_ACCOUNT);
break;
default:
break;
}

return;
}
Expand All @@ -214,58 +159,18 @@ function KYCWall({
chatReportID,
enablePaymentsRoute,
fundList,
getAnchorPosition,
iouReport,
onSuccessfulKYC,
reimbursementAccount?.achData?.state,
selectPaymentMethod,
shouldIncludeDebitCard,
shouldShowAddPaymentMenu,
source,
userWallet?.tierName,
walletTerms?.source,
],
);

useEffect(() => {
let dimensionsSubscription: EmitterSubscription | null = null;

PaymentMethods.kycWallRef.current = {continueAction};

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

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

PaymentMethods.kycWallRef.current = null;
};
}, [chatReportID, setMenuPosition, shouldListenForResize, continueAction]);

return (
<>
<AddPaymentMethodMenu
isVisible={shouldShowAddPaymentMenu}
iouReport={iouReport}
onClose={() => setShouldShowAddPaymentMenu(false)}
anchorRef={anchorRef}
anchorPosition={{
vertical: anchorPosition.anchorPositionVertical,
horizontal: anchorPosition.anchorPositionHorizontal,
}}
anchorAlignment={anchorAlignment}
onItemSelected={(item: PaymentMethod) => {
setShouldShowAddPaymentMenu(false);
selectPaymentMethod(item);
}}
shouldShowPersonalBankAccountOption={shouldShowPersonalBankAccountOption}
/>
{children(continueAction, viewRef(anchorRef))}
</>
);
return <>{children(continueAction, viewRef(anchorRef))}</>;
}
brandonhenry marked this conversation as resolved.
Show resolved Hide resolved

KYCWall.displayName = 'BaseKYCWall';
Expand Down
1 change: 0 additions & 1 deletion src/components/MoneyRequestConfirmationList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,6 @@ function MoneyRequestConfirmationList({
onPress={confirm}
enablePaymentsRoute={ROUTES.IOU_SEND_ENABLE_PAYMENTS}
addBankAccountRoute={bankAccountRoute}
shouldShowPersonalBankAccountOption
currency={iouCurrencyCode}
policyID={policyID}
buttonSize={CONST.DROPDOWN_BUTTON_SIZE.LARGE}
Expand Down
45 changes: 25 additions & 20 deletions src/components/SettlementButton.tsx
brandonhenry marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,6 @@ type SettlementButtonProps = SettlementButtonOnyxProps & {
/** The anchor alignment of the popover menu for KYC wall popover */
kycWallAnchorAlignment?: AnchorAlignment;

/** Whether the personal bank account option should be shown */
shouldShowPersonalBankAccountOption?: boolean;

/** The priority to assign the enter key event listener to buttons. 0 is the highest priority. */
enterKeyEventListenerPriority?: number;

Expand Down Expand Up @@ -147,7 +144,6 @@ function SettlementButton({
shouldShowApproveButton = false,
shouldDisableApproveButton = false,
style,
shouldShowPersonalBankAccountOption = false,
enterKeyEventListenerPriority = 0,
confirmApproval,
policy,
Expand All @@ -169,25 +165,35 @@ function SettlementButton({
const shouldShowPaywithExpensifyOption = !isPaidGroupPolicy || (!shouldHidePaymentOptions && ReportUtils.isPayer(session, iouReport));
const shouldShowPayElsewhereOption = (!isPaidGroupPolicy || policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_MANUAL) && !isInvoiceReport;
const paymentButtonOptions = useMemo(() => {
const buttonOptions = [];
const isExpenseReport = ReportUtils.isExpenseReport(iouReport);
const paymentMethods = {
[CONST.IOU.PAYMENT_TYPE.EXPENSIFY]: {
text: translate('iou.settleExpensify', {formattedAmount}),
icon: Expensicons.Wallet,
value: CONST.IOU.PAYMENT_TYPE.EXPENSIFY,
},
[CONST.IOU.PAYMENT_TYPE.VBBA]: {
text: translate('iou.settleExpensify', {formattedAmount}),
icon: Expensicons.Wallet,
value: CONST.IOU.PAYMENT_TYPE.VBBA,
},
[CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT]: {
text: translate('iou.settlePersonalBank', {formattedAmount}),
icon: Expensicons.Bank,
value: CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT,
},
brandonhenry marked this conversation as resolved.
Show resolved Hide resolved
[CONST.PAYMENT_METHODS.BUSINESS_BANK_ACCOUNT]: {
text: translate('iou.settleBusinessBank', {formattedAmount}),
icon: Expensicons.Bank,
value: CONST.PAYMENT_METHODS.BUSINESS_BANK_ACCOUNT,
},
[CONST.PAYMENT_METHODS.DEBIT_CARD]: {
text: translate('iou.settleDebitCard', {formattedAmount}),
icon: Expensicons.CreditCard,
value: CONST.PAYMENT_METHODS.DEBIT_CARD,
},
brandonhenry marked this conversation as resolved.
Show resolved Hide resolved
[CONST.IOU.PAYMENT_TYPE.ELSEWHERE]: {
text: translate('iou.payElsewhere', {formattedAmount}),
icon: Expensicons.Cash,
value: CONST.IOU.PAYMENT_TYPE.ELSEWHERE,
},
};
const buttonOptions = [];
const approveButtonOption = {
text: translate('iou.approve'),
icon: Expensicons.ThumbsUp,
Expand All @@ -205,12 +211,10 @@ function SettlementButton({
// If the user has previously chosen a specific payment option or paid for some expense,
// let's use the last payment method or use default.
const paymentMethod = nvpLastPaymentMethod?.[policyID] ?? '-1';
if (canUseWallet) {
buttonOptions.push(paymentMethods[CONST.IOU.PAYMENT_TYPE.EXPENSIFY]);
}
if (isExpenseReport && shouldShowPaywithExpensifyOption) {
buttonOptions.push(paymentMethods[CONST.IOU.PAYMENT_TYPE.VBBA]);
if (canUseWallet || (isExpenseReport && shouldShowPaywithExpensifyOption)) {
buttonOptions.push(paymentMethods[CONST.PAYMENT_METHODS.BUSINESS_BANK_ACCOUNT]);
}

if (shouldShowPayElsewhereOption) {
buttonOptions.push(paymentMethods[CONST.IOU.PAYMENT_TYPE.ELSEWHERE]);
}
Expand Down Expand Up @@ -270,7 +274,12 @@ function SettlementButton({
return;
}

if (iouPaymentType === CONST.IOU.PAYMENT_TYPE.EXPENSIFY || iouPaymentType === CONST.IOU.PAYMENT_TYPE.VBBA) {
if (
iouPaymentType === CONST.IOU.PAYMENT_TYPE.VBBA ||
iouPaymentType === CONST.PAYMENT_METHODS.BUSINESS_BANK_ACCOUNT ||
iouPaymentType === CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT ||
iouPaymentType === CONST.PAYMENT_METHODS.DEBIT_CARD
) {
triggerKYCFlow(event, iouPaymentType);
BankAccounts.setPersonalBankAccountContinueKYCOnSuccess(ROUTES.ENABLE_PAYMENTS);
brandonhenry marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like this logic caused the following issue:

Because on unvalidated (gmail) accounts, when a user tries to Pay someone with Expensify, the RHP opens with this page cannot be found screen because of this code from AddPersonalBankAccountPage. We fixed by routing the user to verify their account before Pay with Expensify in case it's unverified.

return;
Expand Down Expand Up @@ -304,18 +313,14 @@ function SettlementButton({
chatReportID={chatReportID}
iouReport={iouReport}
anchorAlignment={kycWallAnchorAlignment}
shouldShowPersonalBankAccountOption={shouldShowPersonalBankAccountOption}
>
{(triggerKYCFlow, buttonRef) => (
<ButtonWithDropdownMenu<PaymentType>
success
onOptionsMenuShow={onPaymentOptionsShow}
onOptionsMenuHide={onPaymentOptionsHide}
buttonRef={buttonRef}
shouldAlwaysShowDropdownMenu={isInvoiceReport}
customText={isInvoiceReport ? translate('iou.settlePayment', {formattedAmount}) : undefined}
menuHeaderText={isInvoiceReport ? translate('workspace.invoices.paymentMethods.chooseInvoiceMethod') : undefined}
isSplitButton={!isInvoiceReport}
isDisabled={isDisabled}
isLoading={isLoading}
onPress={(event, iouPaymentType) => selectPaymentType(event, iouPaymentType, triggerKYCFlow)}
Expand Down
3 changes: 3 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,9 @@ export default {
settlePayment: ({formattedAmount}: SettleExpensifyCardParams) => `Pay ${formattedAmount}`,
settleBusiness: ({formattedAmount}: SettleExpensifyCardParams) => (formattedAmount ? `Pay ${formattedAmount} as a business` : `Pay as a business`),
payElsewhere: ({formattedAmount}: SettleExpensifyCardParams) => (formattedAmount ? `Pay ${formattedAmount} elsewhere` : `Pay elsewhere`),
settlePersonalBank: ({formattedAmount}: SettleExpensifyCardParams) => (formattedAmount ? `Pay ${formattedAmount} with personal bank account` : `Pay with personal bank account`),
settleBusinessBank: ({formattedAmount}: SettleExpensifyCardParams) => (formattedAmount ? `Pay ${formattedAmount} with business bank account` : `Pay with business bank account`),
settleDebitCard: ({formattedAmount}: SettleExpensifyCardParams) => (formattedAmount ? `Pay ${formattedAmount} with debit card` : `Pay with debit card`),
nextStep: 'Next steps',
finished: 'Finished',
sendInvoice: ({amount}: RequestAmountParams) => `Send ${amount} invoice`,
Expand Down
5 changes: 5 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,11 @@ export default {
settlePayment: ({formattedAmount}: SettleExpensifyCardParams) => `Pagar ${formattedAmount}`,
settleBusiness: ({formattedAmount}: SettleExpensifyCardParams) => (formattedAmount ? `Pagar ${formattedAmount} como negocio` : `Pagar como empresa`),
payElsewhere: ({formattedAmount}: SettleExpensifyCardParams) => (formattedAmount ? `Pagar ${formattedAmount} de otra forma` : `Pagar de otra forma`),
settlePersonalBank: ({formattedAmount}: SettleExpensifyCardParams) =>
formattedAmount ? `Pagar ${formattedAmount} con cuenta bancaria personal` : `Pagar con cuenta bancaria personal`,
settleBusinessBank: ({formattedAmount}: SettleExpensifyCardParams) =>
formattedAmount ? `Pagar ${formattedAmount} con cuenta bancaria comercial` : `Pagar con cuenta bancaria comercial`,
settleDebitCard: ({formattedAmount}: SettleExpensifyCardParams) => (formattedAmount ? `Pagar ${formattedAmount} con tarjeta de débito` : `Pagar con tarjeta de débito`),
nextStep: 'Pasos siguientes',
finished: 'Finalizado',
sendInvoice: ({amount}: RequestAmountParams) => `Enviar factura de ${amount}`,
Expand Down
1 change: 1 addition & 0 deletions src/languages/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ type RequestCountParams = {

type SettleExpensifyCardParams = {
formattedAmount: string;
available?: boolean;
};

type RequestAmountParams = {amount: string};
Expand Down
1 change: 0 additions & 1 deletion src/pages/iou/MoneyRequestAmountForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,6 @@ function MoneyRequestAmountForm(
horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.RIGHT,
vertical: CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.BOTTOM,
}}
shouldShowPersonalBankAccountOption
enterKeyEventListenerPriority={1}
/>
) : (
Expand Down
2 changes: 1 addition & 1 deletion src/types/onyx/OriginalMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type ReportActionName from './ReportActionName';
type JoinWorkspaceResolution = ValueOf<typeof CONST.REPORT.ACTIONABLE_MENTION_JOIN_WORKSPACE_RESOLUTION>;

/** Types of payments methods */
type PaymentMethodType = DeepValueOf<typeof CONST.IOU.PAYMENT_TYPE | typeof CONST.IOU.REPORT_ACTION_TYPE | typeof CONST.WALLET.TRANSFER_METHOD_TYPE>;
type PaymentMethodType = DeepValueOf<typeof CONST.IOU.PAYMENT_TYPE | typeof CONST.IOU.REPORT_ACTION_TYPE | typeof CONST.WALLET.TRANSFER_METHOD_TYPE | typeof CONST.PAYMENT_METHODS>;
brandonhenry marked this conversation as resolved.
Show resolved Hide resolved

/** Types of sources of original message */
type OriginalMessageSource = 'Chronos' | 'email' | 'ios' | 'android' | 'web' | '';
Expand Down
Loading