From e37cb157ca71f49c151f071fc464b814d1ee6b7b Mon Sep 17 00:00:00 2001 From: Jules Rosser Date: Wed, 9 Jun 2021 15:24:58 +0100 Subject: [PATCH] update Permissions logic to fix IOU regression --- src/libs/Permissions.js | 6 ++++-- src/pages/iou/IOUDetailsModal.js | 8 +++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/libs/Permissions.js b/src/libs/Permissions.js index 33cfb6084308..f0a981b350b3 100644 --- a/src/libs/Permissions.js +++ b/src/libs/Permissions.js @@ -28,16 +28,18 @@ function canUseIOU(betas) { } /** + * @param {Array} betas * @returns {Boolean} */ -function canUsePayWithExpensify() { +function canUsePayWithExpensify(betas) { return _.contains(betas, CONST.BETAS.PAY_WITH_EXPENSIFY) || canUseAllBetas(); } /** + * @param {Array} betas * @returns {Boolean} */ -function canUseFreePlan() { +function canUseFreePlan(betas) { return _.contains(betas, CONST.BETAS.FREE_PLAN) || canUseAllBetas(); } diff --git a/src/pages/iou/IOUDetailsModal.js b/src/pages/iou/IOUDetailsModal.js index 5b00f2aa5556..878220af9793 100644 --- a/src/pages/iou/IOUDetailsModal.js +++ b/src/pages/iou/IOUDetailsModal.js @@ -67,6 +67,9 @@ const propTypes = { email: PropTypes.string, }).isRequired, + /** Beta features list */ + betas: PropTypes.arrayOf(PropTypes.string).isRequired, + ...withLocalizePropTypes, }; @@ -181,7 +184,7 @@ class IOUDetailsModal extends Component { */ addExpensifyPaymentOptionIfAvailable() { if (lodashGet(this.props, 'iouReport.currency') !== CONST.CURRENCY.USD - || !Permissions.canUsePayWithExpensify()) { + || !Permissions.canUsePayWithExpensify(this.props.betas)) { return; } @@ -286,5 +289,8 @@ export default compose( session: { key: ONYXKEYS.SESSION, }, + betas: { + key: ONYXKEYS.BETAS, + }, }), )(IOUDetailsModal);