From d986f4c320dffdd8d3a522300c507069311d3338 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Fri, 24 Nov 2023 13:55:05 -0700 Subject: [PATCH 1/3] update logic for business bank account payment --- src/components/AddPaymentMethodMenu.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/components/AddPaymentMethodMenu.js b/src/components/AddPaymentMethodMenu.js index ce26985932d6..367771b2529f 100644 --- a/src/components/AddPaymentMethodMenu.js +++ b/src/components/AddPaymentMethodMenu.js @@ -78,13 +78,11 @@ function AddPaymentMethodMenu({isVisible, onClose, anchorPosition, anchorAlignme { text: translate('common.personalBankAccount'), icon: Expensicons.Bank, - onSelected: () => { - onItemSelected(CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT); - }, + onSelected: () => onItemSelected(CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT), }, ] : []), - ...(!ReportActionsUtils.hasRequestFromCurrentAccount(lodashGet(iouReport, 'reportID', 0), lodashGet(session, 'accountID', 0)) + ...(ReportUtils.isExpenseReport(iouReport) ? [ { text: translate('common.businessBankAccount'), From 8dd33095d48fcf8e565c9265c5379d09e082db14 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Fri, 24 Nov 2023 14:08:59 -0700 Subject: [PATCH 2/3] rm hasRequestFromCurrentAccount --- src/libs/ReportActionsUtils.ts | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 333d621167b7..dab5a41c9232 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -631,26 +631,6 @@ function isNotifiableReportAction(reportAction: OnyxEntry): 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 hasRequestFromCurrentAccount(reportID: string, currentAccountID: number): boolean { - 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, @@ -691,7 +671,6 @@ export { isReimbursementQueuedAction, shouldReportActionBeVisible, shouldReportActionBeVisibleAsLastAction, - hasRequestFromCurrentAccount, getFirstVisibleReportActionID, isChannelLogMemberAction, }; From d8e12d0c3175b6e065f412456568101bfdc060f2 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Fri, 24 Nov 2023 14:11:30 -0700 Subject: [PATCH 3/3] rm session --- src/components/AddPaymentMethodMenu.js | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/src/components/AddPaymentMethodMenu.js b/src/components/AddPaymentMethodMenu.js index 367771b2529f..9d7ddb67f0b2 100644 --- a/src/components/AddPaymentMethodMenu.js +++ b/src/components/AddPaymentMethodMenu.js @@ -1,15 +1,10 @@ -import lodashGet from 'lodash/get'; import PropTypes from 'prop-types'; import React from 'react'; -import {withOnyx} from 'react-native-onyx'; import _ from 'underscore'; import useLocalize from '@hooks/useLocalize'; -import compose from '@libs/compose'; -import * as ReportActionsUtils from '@libs/ReportActionsUtils'; import * as ReportUtils from '@libs/ReportUtils'; import iouReportPropTypes from '@pages/iouReportPropTypes'; import CONST from '@src/CONST'; -import ONYXKEYS from '@src/ONYXKEYS'; import * as Expensicons from './Icon/Expensicons'; import PopoverMenu from './PopoverMenu'; import refPropTypes from './refPropTypes'; @@ -42,12 +37,6 @@ const propTypes = { /** Popover anchor ref */ anchorRef: refPropTypes, - - /** Session info for the currently logged in user. */ - session: PropTypes.shape({ - /** Currently logged in user accountID */ - accountID: PropTypes.number, - }), }; const defaultProps = { @@ -58,10 +47,9 @@ const defaultProps = { vertical: CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.BOTTOM, }, anchorRef: () => {}, - session: {}, }; -function AddPaymentMethodMenu({isVisible, onClose, anchorPosition, anchorAlignment, anchorRef, iouReport, onItemSelected, session}) { +function AddPaymentMethodMenu({isVisible, onClose, anchorPosition, anchorAlignment, anchorRef, iouReport, onItemSelected}) { const {translate} = useLocalize(); return ( @@ -108,11 +96,4 @@ AddPaymentMethodMenu.propTypes = propTypes; AddPaymentMethodMenu.defaultProps = defaultProps; AddPaymentMethodMenu.displayName = 'AddPaymentMethodMenu'; -export default compose( - withWindowDimensions, - withOnyx({ - session: { - key: ONYXKEYS.SESSION, - }, - }), -)(AddPaymentMethodMenu); +export default withWindowDimensions(AddPaymentMethodMenu);