diff --git a/src/components/AddPaymentMethodMenu.js b/src/components/AddPaymentMethodMenu.js index ce26985932d6..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 ( @@ -78,13 +66,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'), @@ -110,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); 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, };