|
1 | 1 | import {useRoute} from '@react-navigation/native'; |
2 | 2 | import type {ReactNode} from 'react'; |
3 | | -import React, {useCallback, useEffect, useMemo, useState} from 'react'; |
| 3 | +import React, {useCallback, useContext, useEffect, useMemo, useState} from 'react'; |
4 | 4 | import {View} from 'react-native'; |
5 | 5 | import type {OnyxEntry} from 'react-native-onyx'; |
6 | 6 | import type {ValueOf} from 'type-fest'; |
@@ -41,6 +41,7 @@ import ButtonWithDropdownMenu from './ButtonWithDropdownMenu'; |
41 | 41 | import type {DropdownOption} from './ButtonWithDropdownMenu/types'; |
42 | 42 | import ConfirmModal from './ConfirmModal'; |
43 | 43 | import DecisionModal from './DecisionModal'; |
| 44 | +import {DelegateNoAccessContext} from './DelegateNoAccessModalProvider'; |
44 | 45 | import HeaderWithBackButton from './HeaderWithBackButton'; |
45 | 46 | import Icon from './Icon'; |
46 | 47 | import * as Expensicons from './Icon/Expensicons'; |
@@ -92,7 +93,7 @@ function MoneyRequestHeader({report, parentReportAction, policy, onBackButtonPre |
92 | 93 | const isDuplicate = isDuplicateTransactionUtils(transaction); |
93 | 94 | const reportID = report?.reportID; |
94 | 95 | const {removeTransaction} = useSearchContext(); |
95 | | - |
| 96 | + const {isDelegateAccessRestricted, showDelegateNoAccessModal} = useContext(DelegateNoAccessContext); |
96 | 97 | const isReportInRHP = route.name === SCREENS.SEARCH.REPORT_RHP; |
97 | 98 | const shouldDisplayTransactionNavigation = !!(reportID && isReportInRHP); |
98 | 99 |
|
@@ -214,6 +215,11 @@ function MoneyRequestHeader({report, parentReportAction, policy, onBackButtonPre |
214 | 215 | throw new Error('Parent action does not exist'); |
215 | 216 | } |
216 | 217 |
|
| 218 | + if (isDelegateAccessRestricted) { |
| 219 | + showDelegateNoAccessModal(); |
| 220 | + return; |
| 221 | + } |
| 222 | + |
217 | 223 | changeMoneyRequestHoldStatus(parentReportAction); |
218 | 224 | }, |
219 | 225 | }, |
|
0 commit comments