From 9b26ab0573bb4c44c59c69055956eb0e36fecf95 Mon Sep 17 00:00:00 2001 From: Rory Abraham <47436092+roryabraham@users.noreply.github.com> Date: Wed, 9 Jun 2021 10:30:12 -0700 Subject: [PATCH] Merge pull request #3481 from Expensify/jules-iouFixPermissionsRegression Update Permissions logic to fix IOU regression (cherry picked from commit 64f1307f230dada6e79c80452683e4018f626bcc) --- 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);