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 1 commit
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
77 changes: 61 additions & 16 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 @@ -9,6 +9,8 @@ import playSound, {SOUNDS} from '@libs/Sound';
import * as BankAccounts from '@userActions/BankAccounts';
import * as IOU from '@userActions/IOU';
import * as PaymentMethods from '@userActions/PaymentMethods';
import * as Policy from '@userActions/Policy';
import Navigation from '@libs/Navigation/Navigation';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
Expand Down Expand Up @@ -147,6 +149,21 @@ function SettlementButton({
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,
Expand All @@ -169,12 +186,22 @@ function SettlementButton({
// If the user has previously chosen a specific payment option or paid for some request or expense,
// let's use the last payment method or use default.
const paymentMethod = nvpLastPaymentMethod?.[policyID] ?? '';
if (canUseWallet) {
buttonOptions.push(paymentMethods[CONST.IOU.PAYMENT_TYPE.EXPENSIFY]);
}
if (isExpenseReport) {
buttonOptions.push(paymentMethods[CONST.IOU.PAYMENT_TYPE.VBBA]);
}

// no longer want to show these options based on https://github.com/Expensify/App/issues/33967
// PR issue: https://github.com/Expensify/App/issues/36301
// what needs to happen to backend to support?

// if (canUseWallet) {
// buttonOptions.push(paymentMethods[CONST.IOU.PAYMENT_TYPE.EXPENSIFY]);
// }
// if (isExpenseReport) {
// buttonOptions.push(paymentMethods[CONST.IOU.PAYMENT_TYPE.VBBA]);
// }

buttonOptions.push(paymentMethods[CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT]);
buttonOptions.push(paymentMethods[CONST.PAYMENT_METHODS.BUSINESS_BANK_ACCOUNT]);
buttonOptions.push(paymentMethods[CONST.PAYMENT_METHODS.DEBIT_CARD]);

buttonOptions.push(paymentMethods[CONST.IOU.PAYMENT_TYPE.ELSEWHERE]);

if (shouldShowApproveButton) {
Expand All @@ -190,16 +217,34 @@ function SettlementButton({
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [currency, formattedAmount, iouReport, policyID, translate, shouldHidePaymentOptions, shouldShowApproveButton]);

const selectPaymentType = (event: KYCFlowEvent, iouPaymentType: PaymentMethodType, triggerKYCFlow: TriggerKYCFlow) => {
if (iouPaymentType === CONST.IOU.PAYMENT_TYPE.EXPENSIFY || iouPaymentType === CONST.IOU.PAYMENT_TYPE.VBBA) {
triggerKYCFlow(event, iouPaymentType);
BankAccounts.setPersonalBankAccountContinueKYCOnSuccess(ROUTES.ENABLE_PAYMENTS);
brandonhenry marked this conversation as resolved.
Show resolved Hide resolved
return;
}

if (iouPaymentType === CONST.IOU.REPORT_ACTION_TYPE.APPROVE) {
IOU.approveMoneyRequest(iouReport ?? {});
return;
const selectPaymentType = (event: KYCFlowEvent, iouPaymentType: PaymentMethodType , triggerKYCFlow: TriggerKYCFlow) => {
switch (iouPaymentType){
case CONST.IOU.PAYMENT_TYPE.EXPENSIFY:
case CONST.IOU.PAYMENT_TYPE.VBBA:
// this case i no longer supported as we removed these options per https://github.com/Expensify/App/issues/33967
// PR issue: https://github.com/Expensify/App/issues/36301
// is this safe to remove?
triggerKYCFlow(event, iouPaymentType);
BankAccounts.setPersonalBankAccountContinueKYCOnSuccess(ROUTES.ENABLE_PAYMENTS);
return;
case CONST.PAYMENT_METHODS.BUSINESS_BANK_ACCOUNT:
if (iouReport && ReportUtils.isIOUReport(iouReport)) {
const policyID = Policy.createWorkspaceFromIOUPayment(iouReport);
// Navigate to the bank account set up flow for this specific policy
Navigation.navigate(ROUTES.BANK_ACCOUNT_WITH_STEP_TO_OPEN.getRoute('', policyID));
return;
}
Navigation.navigate(addBankAccountRoute);
return;
case CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT:
BankAccounts.openPersonalBankAccountSetupView();
return;
case CONST.PAYMENT_METHODS.DEBIT_CARD:
Navigation.navigate(addDebitCardRoute);
return;
case CONST.IOU.REPORT_ACTION_TYPE.APPROVE:
IOU.approveMoneyRequest(iouReport ?? {});
return;
}

playSound(SOUNDS.DONE);
Expand Down
3 changes: 3 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,9 @@ export default {
settledElsewhere: 'Paid elsewhere',
settleExpensify: ({formattedAmount}: SettleExpensifyCardParams) => (formattedAmount ? `Pay ${formattedAmount} with Expensify` : `Pay with Expensify`),
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',
requestAmount: ({amount}: RequestAmountParams) => `request ${amount}`,
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 @@ -2,7 +2,7 @@ import type {ValueOf} from 'type-fest';
import type CONST from '@src/CONST';
import type DeepValueOf from '@src/types/utils/DeepValueOf';

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

type ActionName = DeepValueOf<typeof CONST.REPORT.ACTIONS.TYPE>;
type OriginalMessageActionName =
Expand Down
Loading