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

Personal bank account option is not present in Pay with Expensify menu #32423

Merged
merged 7 commits into from
Dec 14, 2023
Merged
Changes from 3 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
14 changes: 12 additions & 2 deletions src/components/AddPaymentMethodMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import useLocalize from '@hooks/useLocalize';
import compose from '@libs/compose';
import * as ReportActionsUtils from '@libs/ReportActionsUtils';
import * as ReportUtils from '@libs/ReportUtils';
import {iouDefaultProps, iouPropTypes} from '@pages/iou/propTypes';
import iouReportPropTypes from '@pages/iouReportPropTypes';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
Expand Down Expand Up @@ -48,6 +49,9 @@ const propTypes = {
/** Currently logged in user accountID */
accountID: PropTypes.number,
}),

/** Holds data related to Money Request view state, rather than the underlying Money Request data. */
iou: iouPropTypes,
};

const defaultProps = {
Expand All @@ -59,9 +63,10 @@ const defaultProps = {
},
anchorRef: () => {},
session: {},
iou: iouDefaultProps,
};

function AddPaymentMethodMenu({isVisible, onClose, anchorPosition, anchorAlignment, anchorRef, iouReport, onItemSelected, session}) {
function AddPaymentMethodMenu({isVisible, onClose, anchorPosition, anchorAlignment, anchorRef, iouReport, onItemSelected, session, iou}) {
const {translate} = useLocalize();

// Users can choose to pay with business bank account in case of Expense reports or in case of P2P IOU report
Expand All @@ -70,6 +75,8 @@ function AddPaymentMethodMenu({isVisible, onClose, anchorPosition, anchorAlignme
ReportUtils.isExpenseReport(iouReport) ||
(ReportUtils.isIOUReport(iouReport) && !ReportActionsUtils.hasRequestFromCurrentAccount(lodashGet(iouReport, 'reportID', 0), lodashGet(session, 'accountID', 0)));

const canUsePersonalBankAccount = iou.id === CONST.IOU.TYPE.SEND || ReportUtils.isIOUReport(iouReport);

return (
<PopoverMenu
isVisible={isVisible}
Expand All @@ -79,7 +86,7 @@ function AddPaymentMethodMenu({isVisible, onClose, anchorPosition, anchorAlignme
anchorRef={anchorRef}
onItemSelected={onClose}
menuItems={[
...(ReportUtils.isIOUReport(iouReport)
...(canUsePersonalBankAccount
? [
{
text: translate('common.personalBankAccount'),
Expand Down Expand Up @@ -122,5 +129,8 @@ export default compose(
session: {
key: ONYXKEYS.SESSION,
},
iou: {
key: ONYXKEYS.IOU,
},
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not correct check of IOU type.
There's case when iou.type is undefined

bug.mov
onyx

Copy link
Contributor

Choose a reason for hiding this comment

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

@dukenv0307 bump ^
I see you're currently working on lots of issues.
If you're not able to prioritize, we can open back to proposals

}),
)(AddPaymentMethodMenu);
Loading