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

Create v1 Collect workspace Bottom Up flow #30582

Merged
merged 33 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
8f961ac
Add a new button to the payment methods popover
mountiny Oct 20, 2023
6c8bd19
Add the business bank account option
mountiny Oct 21, 2023
1a46590
Work on the Bottom Up flow command
mountiny Oct 22, 2023
e68e8a8
Merge main
mountiny Oct 23, 2023
34064f5
Merge main
mountiny Oct 30, 2023
b1b8349
Fix merge conflict
mountiny Nov 1, 2023
7ab658f
Merge branch 'main' into vit-bottomUp
mountiny Nov 2, 2023
c814ade
Fix issues in the flow
mountiny Nov 2, 2023
cfe141b
Update the personal bank account const name
mountiny Nov 2, 2023
ae33908
Flow clean up
mountiny Nov 2, 2023
b6030a9
Merge branch 'main' into vit-bottomUp
mountiny Nov 2, 2023
93d176c
Offer correct payment options
mountiny Nov 3, 2023
ec8974c
Merge branch 'main' into vit-bottomUp
mountiny Nov 3, 2023
b9844f6
Make sure to update the report total and transaction amounts
mountiny Nov 3, 2023
fc25fde
Add moved report action
mountiny Nov 3, 2023
4655e8f
Fix crashes
mountiny Nov 4, 2023
c9a9ec4
Merge main
mountiny Nov 8, 2023
23dda79
Move the navigation action out of Policy action
mountiny Nov 9, 2023
bcaece0
Merge branch 'main' into vit-bottomUp
mountiny Nov 9, 2023
16df5ae
Merge branch 'main' into vit-bottomUp
mountiny Nov 10, 2023
59e4026
Remove logs
mountiny Nov 10, 2023
95d7849
Merge branch 'main' into vit-bottomUp
mountiny Nov 10, 2023
f9a2af1
Clean up the code
mountiny Nov 10, 2023
93f3475
Fix lint and clean up some code
mountiny Nov 10, 2023
43aaa43
Fix lint
mountiny Nov 10, 2023
c599cde
Merge branch 'main' into vit-bottomUp
mountiny Nov 15, 2023
2437282
Destructure props and change session propTypes in the AddPaymentMetho…
mountiny Nov 15, 2023
733067b
Handle transactions in merge collection, prettier and translations
mountiny Nov 15, 2023
6765abd
Clean up the GBR in the bottom up flow
mountiny Nov 15, 2023
7aeeef6
Add props for onItemSelected
mountiny Nov 15, 2023
2e5baf2
Merge branch 'main' into vit-bottomUp
mountiny Nov 16, 2023
5a5e494
Merge branch 'main' into vit-bottomUp
mountiny Nov 20, 2023
7bf4260
Address PR review feedback
mountiny Nov 20, 2023
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
5 changes: 3 additions & 2 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1113,6 +1113,7 @@ const CONST = {
PAYMENT_METHODS: {
DEBIT_CARD: 'debitCard',
BANK_ACCOUNT: 'bankAccount',
mountiny marked this conversation as resolved.
Show resolved Hide resolved
BUSINESS_BANK_ACCOUNT: 'businessBankAccount',
},

PAYMENT_METHOD_ID_KEYS: {
Expand Down Expand Up @@ -1201,8 +1202,8 @@ const CONST = {
TYPE: {
FREE: 'free',
PERSONAL: 'personal',
CORPORATE: 'corporate',
TEAM: 'team',
CORPORATE: 'corporate', // aka Control
TEAM: 'team', // aka Collect
mountiny marked this conversation as resolved.
Show resolved Hide resolved
},
ROLE: {
ADMIN: 'admin',
Expand Down
31 changes: 30 additions & 1 deletion src/components/AddPaymentMethodMenu.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import PropTypes from 'prop-types';
import React from 'react';
import {withOnyx} from 'react-native-onyx';
import lodashGet from 'lodash/get';
import _ from 'underscore';
import compose from '@libs/compose';
import Permissions from '@libs/Permissions';
Expand All @@ -9,6 +10,9 @@ import ONYXKEYS from '@src/ONYXKEYS';
import * as Expensicons from './Icon/Expensicons';
import PopoverMenu from './PopoverMenu';
import refPropTypes from './refPropTypes';
import iouReportPropTypes from '../pages/iouReportPropTypes';
import * as ReportUtils from '../libs/ReportUtils';
import * as ReportActionsUtils from '../libs/ReportActionsUtils';
import withLocalize, {withLocalizePropTypes} from './withLocalize';
import withWindowDimensions from './withWindowDimensions';

Expand All @@ -19,6 +23,9 @@ const propTypes = {
/** Callback to execute when the component closes. */
onClose: PropTypes.func.isRequired,

/** The IOU/Expense report we are paying */
iouReport: iouReportPropTypes,

/** Anchor position for the AddPaymentMenu. */
anchorPosition: PropTypes.shape({
horizontal: PropTypes.number,
Expand All @@ -37,17 +44,27 @@ const propTypes = {
/** Popover anchor ref */
anchorRef: refPropTypes,

/** Session info for the currently logged in user. */
session: PropTypes.shape({
mountiny marked this conversation as resolved.
Show resolved Hide resolved
/** Currently logged in user accountID */
accountID: PropTypes.number,
}),

...withLocalizePropTypes,
};

const defaultProps = {
iouReport: {},
anchorPosition: {},
anchorAlignment: {
horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.LEFT,
vertical: CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.BOTTOM,
},
betas: [],
anchorRef: () => {},
session: {
accountID: 0,
mountiny marked this conversation as resolved.
Show resolved Hide resolved
},
};

function AddPaymentMethodMenu(props) {
mountiny marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -61,12 +78,21 @@ function AddPaymentMethodMenu(props) {
onItemSelected={props.onClose}
menuItems={[
{
text: props.translate('common.bankAccount'),
text: props.translate('common.personalBankAccount'),
icon: Expensicons.Bank,
onSelected: () => {
props.onItemSelected(CONST.PAYMENT_METHODS.BANK_ACCOUNT);
},
},
Copy link
Contributor

Choose a reason for hiding this comment

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

This also removed personal bank account option in Wallet page. Issue: #32079

...(ReportUtils.isIOUReport(this.props.iouReport) && ReportActionsUtils.hasRequestFromPayer(lodashGet(this.props.iouReport, 'reportID', 0), this.props.session.accountID)
mountiny marked this conversation as resolved.
Show resolved Hide resolved
? [
{
text: props.translate('common.businessBankAccount'),
icon: Expensicons.Workspace,
onSelected: () => props.onItemSelected(CONST.PAYMENT_METHODS.BUSINESS_BANK_ACCOUNT),
},
]
: []),
...(Permissions.canUseWallet(props.betas)
? [
{
Expand All @@ -93,5 +119,8 @@ export default compose(
betas: {
key: ONYXKEYS.BETAS,
},
session: {
key: ONYXKEYS.SESSION,
},
}),
)(AddPaymentMethodMenu);
3 changes: 3 additions & 0 deletions src/components/KYCWall/BaseKYCWall.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ class KYCWall extends React.Component {
Navigation.navigate(this.props.addBankAccountRoute);
} else if (paymentMethod === CONST.PAYMENT_METHODS.DEBIT_CARD) {
Navigation.navigate(this.props.addDebitCardRoute);
} else if (paymentMethod === CONST.PAYMENT_METHODS.BUSINESS_BANK_ACCOUNT) {
Policy.startCollectFlow(this.props.iouReport);
}
}

Expand Down Expand Up @@ -164,6 +166,7 @@ class KYCWall extends React.Component {
<>
<AddPaymentMethodMenu
isVisible={this.state.shouldShowAddPaymentMenu}
iouReport={this.props.iouReport}
onClose={() => this.setState({shouldShowAddPaymentMenu: false})}
anchorRef={this.anchorRef}
anchorPosition={{
Expand Down
2 changes: 2 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ export default {
more: 'More',
debitCard: 'Debit card',
bankAccount: 'Bank account',
personalBankAccount: 'Personal bank account',
businessBankAccount: 'Business bank account',
join: 'Join',
joinThread: 'Join thread',
decline: 'Decline',
Expand Down
2 changes: 2 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ export default {
more: 'Más',
debitCard: 'Tarjeta de débito',
bankAccount: 'Cuenta bancaria',
personalBankAccount: 'Personal bank account',
businessBankAccount: 'Business bank account',
mountiny marked this conversation as resolved.
Show resolved Hide resolved
join: 'Unirse',
joinThread: 'Unirse al hilo',
decline: 'Rechazar',
Expand Down
21 changes: 21 additions & 0 deletions src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,26 @@ function isNotifiableReportAction(reportAction: OnyxEntry<ReportAction>): boolea
return actions.includes(reportAction.actionName);
}

/**
* Helper method to determine if the provided accountID has made a request on the specified report.
*
* @param reportID
* @param currentAccountID
* @returns
*/
function hasRequestFromPayer(reportID: string, currentAccountID: number): boolean {
mountiny marked this conversation as resolved.
Show resolved Hide resolved
if (!reportID) {
return false;
}

const reportActions = Object.values(getAllReportActions(reportID));
if (reportActions.length === 0) {
return false;
}

return reportActions.some((action) => action.actionName === CONST.REPORT.ACTIONS.TYPE.IOU && action.actorAccountID === currentAccountID);
}

export {
extractLinksFromMessageHtml,
getAllReportActions,
Expand Down Expand Up @@ -656,5 +676,6 @@ export {
isReimbursementQueuedAction,
shouldReportActionBeVisible,
shouldReportActionBeVisibleAsLastAction,
hasRequestFromPayer,
getFirstVisibleReportActionID,
};
Loading