From a55e44c0ba8b9dab38399dc97ffc07dd8a20cdf3 Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Thu, 16 Nov 2023 13:00:41 +0530 Subject: [PATCH 1/3] import Permissions lib --- src/components/ReportActionItem/MoneyRequestView.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/ReportActionItem/MoneyRequestView.js b/src/components/ReportActionItem/MoneyRequestView.js index 5b9a1b2212c7..193a681b7d3b 100644 --- a/src/components/ReportActionItem/MoneyRequestView.js +++ b/src/components/ReportActionItem/MoneyRequestView.js @@ -37,6 +37,7 @@ import * as IOU from '@userActions/IOU'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; +import Permissions from '@libs/Permissions'; import ReportActionItemImage from './ReportActionItemImage'; const propTypes = { From ee6256edc7eb3abdb81d7bf93c65989b8194cd17 Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Thu, 16 Nov 2023 14:11:05 +0530 Subject: [PATCH 2/3] Fix permissions checking --- src/components/ReportActionItem/MoneyRequestView.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.js b/src/components/ReportActionItem/MoneyRequestView.js index 193a681b7d3b..3ab37cf6bc4f 100644 --- a/src/components/ReportActionItem/MoneyRequestView.js +++ b/src/components/ReportActionItem/MoneyRequestView.js @@ -37,7 +37,7 @@ import * as IOU from '@userActions/IOU'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; -import Permissions from '@libs/Permissions'; +import usePermissions from '@hooks/usePermissions'; import ReportActionItemImage from './ReportActionItemImage'; const propTypes = { @@ -77,6 +77,7 @@ const defaultProps = { function MoneyRequestView({report, parentReport, policyCategories, shouldShowHorizontalRule, transaction, policyTags, policy}) { const {isSmallScreenWidth} = useWindowDimensions(); const {translate} = useLocalize(); + const {canUseViolations} = usePermissions(); const parentReportAction = ReportActionsUtils.getParentReportAction(report); const moneyRequestReport = parentReport; const { @@ -174,7 +175,7 @@ function MoneyRequestView({report, parentReport, policyCategories, shouldShowHor )} - {!hasReceipt && canEdit && !isSettled && Permissions.canUseViolations() && ( + {!hasReceipt && canEdit && !isSettled && canUseViolations && ( Navigation.navigate(ROUTES.EDIT_REQUEST.getRoute(report.reportID, CONST.EDIT_REQUEST_FIELD.RECEIPT))} From 5d87ad92f7c61b2d2ff45952dbdac89e7f1edf2b Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Thu, 16 Nov 2023 14:54:14 +0530 Subject: [PATCH 3/3] Fix import order --- src/components/ReportActionItem/MoneyRequestView.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.js b/src/components/ReportActionItem/MoneyRequestView.js index 3ab37cf6bc4f..85ecb914439a 100644 --- a/src/components/ReportActionItem/MoneyRequestView.js +++ b/src/components/ReportActionItem/MoneyRequestView.js @@ -16,6 +16,7 @@ import Text from '@components/Text'; import transactionPropTypes from '@components/transactionPropTypes'; import withCurrentUserPersonalDetails, {withCurrentUserPersonalDetailsPropTypes} from '@components/withCurrentUserPersonalDetails'; import useLocalize from '@hooks/useLocalize'; +import usePermissions from '@hooks/usePermissions'; import useWindowDimensions from '@hooks/useWindowDimensions'; import * as CardUtils from '@libs/CardUtils'; import compose from '@libs/compose'; @@ -37,7 +38,6 @@ import * as IOU from '@userActions/IOU'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; -import usePermissions from '@hooks/usePermissions'; import ReportActionItemImage from './ReportActionItemImage'; const propTypes = {