From 59410f78f012c8eb17195841f9a4c72c9d27e5ba Mon Sep 17 00:00:00 2001 From: Yuwen Memon Date: Mon, 15 Dec 2025 10:12:20 -0800 Subject: [PATCH] Revert "Merge pull request #75821 from mukhrr/fix/75171" This reverts commit 306e38f6f0a3f2db3093efb21bc23d18061dc95d, reversing changes made to e18b8bb604afe73d4ab85f4f77fb09ef32a40ec0. --- src/components/MoneyReportHeader.tsx | 5 -- src/components/MoneyRequestHeader.tsx | 5 -- .../SearchPageHeader/SearchFiltersBar.tsx | 12 ++--- .../Search/ActionCell.tsx | 12 +---- .../Search/ExpenseReportListItem.tsx | 20 +------ .../Search/ReportListItemHeader.tsx | 6 +-- .../Search/TransactionListItem.tsx | 22 +------- src/libs/actions/Search.ts | 54 ++++--------------- src/pages/Search/SearchPage.tsx | 32 +---------- src/pages/Search/SearchSelectedNarrow.tsx | 12 ++--- 10 files changed, 27 insertions(+), 153 deletions(-) diff --git a/src/components/MoneyReportHeader.tsx b/src/components/MoneyReportHeader.tsx index c97b6e6cc65e..c5c35d34630e 100644 --- a/src/components/MoneyReportHeader.tsx +++ b/src/components/MoneyReportHeader.tsx @@ -1346,11 +1346,6 @@ function MoneyReportHeader({ icon: expensifyIcons.ThumbsDown, value: CONST.REPORT.SECONDARY_ACTIONS.REJECT, onSelected: () => { - if (isDelegateAccessRestricted) { - showDelegateNoAccessModal(); - return; - } - if (dismissedRejectUseExplanation) { if (requestParentReportAction) { rejectMoneyRequestReason(requestParentReportAction); diff --git a/src/components/MoneyRequestHeader.tsx b/src/components/MoneyRequestHeader.tsx index c876c363f1c1..bd2ceaf81db6 100644 --- a/src/components/MoneyRequestHeader.tsx +++ b/src/components/MoneyRequestHeader.tsx @@ -435,11 +435,6 @@ function MoneyRequestHeader({report, parentReportAction, policy, onBackButtonPre icon: Expensicons.ThumbsDown, value: CONST.REPORT.TRANSACTION_SECONDARY_ACTIONS.REJECT, onSelected: () => { - if (isDelegateAccessRestricted) { - showDelegateNoAccessModal(); - return; - } - if (dismissedRejectUseExplanation) { if (parentReportAction) { rejectMoneyRequestReason(parentReportAction); diff --git a/src/components/Search/SearchPageHeader/SearchFiltersBar.tsx b/src/components/Search/SearchPageHeader/SearchFiltersBar.tsx index e64e015a73ca..2b820f11c3ce 100644 --- a/src/components/Search/SearchPageHeader/SearchFiltersBar.tsx +++ b/src/components/Search/SearchPageHeader/SearchFiltersBar.tsx @@ -8,7 +8,6 @@ import {FlatList, View} from 'react-native'; import Button from '@components/Button'; import ButtonWithDropdownMenu from '@components/ButtonWithDropdownMenu'; import type {DropdownOption} from '@components/ButtonWithDropdownMenu/types'; -import {DelegateNoAccessContext} from '@components/DelegateNoAccessModalProvider'; import KYCWall from '@components/KYCWall'; import {KYCWallContext} from '@components/KYCWall/KYCWallContext'; import type {PaymentMethodType} from '@components/KYCWall/types'; @@ -115,7 +114,6 @@ function SearchFiltersBar({ const {isAccountLocked, showLockedAccountModal} = useContext(LockedAccountContext); const [searchResultsErrors] = useOnyx(`${ONYXKEYS.COLLECTION.SNAPSHOT}${hash}`, {canBeMissing: true, selector: searchResultsErrorSelector}); const expensifyIcons = useMemoizedLazyExpensifyIcons(['Filter'] as const); - const {isDelegateAccessRestricted, showDelegateNoAccessModal} = useContext(DelegateNoAccessContext); const taxRates = getAllTaxRates(allPolicies); @@ -833,19 +831,17 @@ function SearchFiltersBar({ customText={selectionButtonText} options={headerButtonsOptions} onSubItemSelected={(subItem) => - handleBulkPayItemSelected({ - item: subItem, + handleBulkPayItemSelected( + subItem, triggerKYCFlow, isAccountLocked, showLockedAccountModal, - policy: currentPolicy, + currentPolicy, latestBankItems, activeAdminPolicies, isUserValidated, - isDelegateAccessRestricted, - showDelegateNoAccessModal, confirmPayment, - }) + ) } isSplitButton={false} buttonRef={buttonRef} diff --git a/src/components/SelectionListWithSections/Search/ActionCell.tsx b/src/components/SelectionListWithSections/Search/ActionCell.tsx index 625be14184df..b7e59148d801 100644 --- a/src/components/SelectionListWithSections/Search/ActionCell.tsx +++ b/src/components/SelectionListWithSections/Search/ActionCell.tsx @@ -1,9 +1,8 @@ -import React, {useCallback, useContext} from 'react'; +import React, {useCallback} from 'react'; import {View} from 'react-native'; import type {ValueOf} from 'type-fest'; import Badge from '@components/Badge'; import Button from '@components/Button'; -import {DelegateNoAccessContext} from '@components/DelegateNoAccessModalProvider'; import type {PaymentMethod} from '@components/KYCWall/types'; import {SearchScopeProvider} from '@components/Search/SearchScopeProvider'; import SettlementButton from '@components/SettlementButton'; @@ -73,7 +72,6 @@ function ActionCell({ const styles = useThemeStyles(); const StyleUtils = useStyleUtils(); const {isOffline} = useNetwork(); - const {isDelegateAccessRestricted, showDelegateNoAccessModal} = useContext(DelegateNoAccessContext); const expensifyIcons = useMemoizedLazyExpensifyIcons(['Checkmark', 'Checkbox'] as const); const [iouReport, transactions] = useReportWithTransactionsAndViolations(reportID); const policy = usePolicy(policyID); @@ -90,16 +88,10 @@ function ActionCell({ if (!type || !reportID || !hash || !amount) { return; } - - if (isDelegateAccessRestricted) { - showDelegateNoAccessModal(); - return; - } - const invoiceParams = getPayMoneyOnSearchInvoiceParams(policyID, payAsBusiness, methodID, paymentMethod); payMoneyRequestOnSearch(hash, [{amount, paymentType: type, reportID, ...(isInvoiceReport(iouReport) ? invoiceParams : {})}]); }, - [reportID, hash, amount, policyID, iouReport, isDelegateAccessRestricted, showDelegateNoAccessModal], + [reportID, hash, amount, policyID, iouReport], ); if (!isChildListItem && ((parentAction !== CONST.SEARCH.ACTION_TYPES.PAID && action === CONST.SEARCH.ACTION_TYPES.PAID) || action === CONST.SEARCH.ACTION_TYPES.DONE)) { diff --git a/src/components/SelectionListWithSections/Search/ExpenseReportListItem.tsx b/src/components/SelectionListWithSections/Search/ExpenseReportListItem.tsx index 2d36a161f7a3..ecfb4169c1a6 100644 --- a/src/components/SelectionListWithSections/Search/ExpenseReportListItem.tsx +++ b/src/components/SelectionListWithSections/Search/ExpenseReportListItem.tsx @@ -1,6 +1,5 @@ -import React, {useCallback, useContext, useMemo} from 'react'; +import React, {useCallback, useMemo} from 'react'; import {View} from 'react-native'; -import {DelegateNoAccessContext} from '@components/DelegateNoAccessModalProvider'; import Icon from '@components/Icon'; import {useSearchContext} from '@components/Search/SearchContext'; import BaseListItem from '@components/SelectionListWithSections/BaseListItem'; @@ -60,8 +59,6 @@ function ExpenseReportListItem({ return isEmpty ?? reportItem.isDisabled ?? reportItem.isDisabledCheckbox; }, [reportItem.isDisabled, reportItem.isDisabledCheckbox, reportItem.transactions.length]); - const {isDelegateAccessRestricted, showDelegateNoAccessModal} = useContext(DelegateNoAccessContext); - const handleOnButtonPress = useCallback(() => { handleActionButtonPress( currentSearchHash, @@ -72,21 +69,8 @@ function ExpenseReportListItem({ lastPaymentMethod, currentSearchKey, onDEWModalOpen, - isDelegateAccessRestricted, - showDelegateNoAccessModal, ); - }, [ - currentSearchHash, - reportItem, - onSelectRow, - snapshotReport, - snapshotPolicy, - lastPaymentMethod, - currentSearchKey, - onDEWModalOpen, - isDelegateAccessRestricted, - showDelegateNoAccessModal, - ]); + }, [currentSearchHash, reportItem, onSelectRow, snapshotReport, snapshotPolicy, lastPaymentMethod, currentSearchKey, onDEWModalOpen]); const handleCheckboxPress = useCallback(() => { onCheckboxPress?.(reportItem as unknown as TItem); diff --git a/src/components/SelectionListWithSections/Search/ReportListItemHeader.tsx b/src/components/SelectionListWithSections/Search/ReportListItemHeader.tsx index f93076f1b1a7..409c422e155f 100644 --- a/src/components/SelectionListWithSections/Search/ReportListItemHeader.tsx +++ b/src/components/SelectionListWithSections/Search/ReportListItemHeader.tsx @@ -1,8 +1,7 @@ -import React, {useContext, useMemo} from 'react'; +import React, {useMemo} from 'react'; import {View} from 'react-native'; import type {ColorValue} from 'react-native'; import Checkbox from '@components/Checkbox'; -import {DelegateNoAccessContext} from '@components/DelegateNoAccessModalProvider'; import Icon from '@components/Icon'; import * as Expensicons from '@components/Icon/Expensicons'; import {PressableWithFeedback} from '@components/Pressable'; @@ -224,7 +223,6 @@ function ReportListItemHeader({ const snapshotPolicy = useMemo(() => { return (snapshot?.data?.[`${ONYXKEYS.COLLECTION.POLICY}${reportItem.policyID}`] ?? {}) as Policy; }, [snapshot, reportItem.policyID]); - const {isDelegateAccessRestricted, showDelegateNoAccessModal} = useContext(DelegateNoAccessContext); const avatarBorderColor = StyleUtils.getItemBackgroundColorStyle(!!reportItem.isSelected, !!isFocused || !!isHovered, !!isDisabled, theme.activeComponentBG, theme.hoverComponentBG)?.backgroundColor ?? theme.highlightBG; @@ -239,8 +237,6 @@ function ReportListItemHeader({ lastPaymentMethod, currentSearchKey, onDEWModalOpen, - isDelegateAccessRestricted, - showDelegateNoAccessModal, ); }; return !isLargeScreenWidth ? ( diff --git a/src/components/SelectionListWithSections/Search/TransactionListItem.tsx b/src/components/SelectionListWithSections/Search/TransactionListItem.tsx index da8b1707a2fc..5ff07ffcf20f 100644 --- a/src/components/SelectionListWithSections/Search/TransactionListItem.tsx +++ b/src/components/SelectionListWithSections/Search/TransactionListItem.tsx @@ -1,11 +1,10 @@ -import React, {useCallback, useContext, useMemo, useRef} from 'react'; +import React, {useCallback, useMemo, useRef} from 'react'; import type {View} from 'react-native'; import type {OnyxEntry} from 'react-native-onyx'; // Use the original useOnyx hook to get the real-time data from Onyx and not from the snapshot // eslint-disable-next-line no-restricted-imports import {useOnyx as originalUseOnyx} from 'react-native-onyx'; import {getButtonRole} from '@components/Button/utils'; -import {DelegateNoAccessContext} from '@components/DelegateNoAccessModalProvider'; import OfflineWithFeedback from '@components/OfflineWithFeedback'; import PressableWithFeedback from '@components/Pressable/PressableWithFeedback'; import {useSearchContext} from '@components/Search/SearchContext'; @@ -114,8 +113,6 @@ function TransactionListItem({ ); }, [snapshotPolicy, snapshotReport, transactionItem, violations, currentUserDetails.email, currentUserDetails.accountID]); - const {isDelegateAccessRestricted, showDelegateNoAccessModal} = useContext(DelegateNoAccessContext); - const handleActionButtonPress = useCallback(() => { handleActionButtonPressUtil( currentSearchHash, @@ -126,23 +123,8 @@ function TransactionListItem({ lastPaymentMethod, currentSearchKey, onDEWModalOpen, - isDelegateAccessRestricted, - showDelegateNoAccessModal, ); - }, [ - currentSearchHash, - transactionItem, - transactionPreviewData, - snapshotReport, - snapshotPolicy, - lastPaymentMethod, - currentSearchKey, - onSelectRow, - item, - onDEWModalOpen, - isDelegateAccessRestricted, - showDelegateNoAccessModal, - ]); + }, [currentSearchHash, transactionItem, transactionPreviewData, snapshotReport, snapshotPolicy, lastPaymentMethod, currentSearchKey, onSelectRow, item, onDEWModalOpen]); const handleCheckboxPress = useCallback(() => { onCheckboxPress?.(item); diff --git a/src/libs/actions/Search.ts b/src/libs/actions/Search.ts index f98c0c83bdd0..93b81c8c3400 100644 --- a/src/libs/actions/Search.ts +++ b/src/libs/actions/Search.ts @@ -78,8 +78,6 @@ function handleActionButtonPress( lastPaymentMethod: OnyxEntry, currentSearchKey?: SearchKey, onDEWModalOpen?: () => void, - isDelegateAccessRestricted?: boolean, - onDelegateAccessRestricted?: () => void, ) { // The transactionIDList is needed to handle actions taken on `status:""` where transactions on single expense reports can be approved/paid. // We need the transactionID to display the loading indicator for that list item's action. @@ -94,17 +92,9 @@ function handleActionButtonPress( switch (item.action) { case CONST.SEARCH.ACTION_TYPES.PAY: - if (isDelegateAccessRestricted) { - onDelegateAccessRestricted?.(); - return; - } getPayActionCallback(hash, item, goToItem, snapshotReport, snapshotPolicy, lastPaymentMethod, currentSearchKey); return; case CONST.SEARCH.ACTION_TYPES.APPROVE: - if (isDelegateAccessRestricted) { - onDelegateAccessRestricted?.(); - return; - } if (hasDynamicExternalWorkflow(snapshotPolicy)) { onDEWModalOpen?.(); return; @@ -1039,39 +1029,17 @@ function isValidBulkPayOption(item: PopoverMenuItem) { /** * Handles the click event when user selects bulk pay action. */ -function handleBulkPayItemSelected(params: { - item: PopoverMenuItem; - triggerKYCFlow: (params: ContinueActionParams) => void; - isAccountLocked: boolean; - showLockedAccountModal: () => void; - policy: OnyxEntry; - latestBankItems: BankAccountMenuItem[] | undefined; - activeAdminPolicies: Policy[]; - isUserValidated: boolean | undefined; - isDelegateAccessRestricted: boolean; - showDelegateNoAccessModal: () => void; - confirmPayment?: (paymentType: PaymentMethodType | undefined, additionalData?: Record) => void; -}) { - const { - item, - triggerKYCFlow, - isAccountLocked, - showLockedAccountModal, - policy, - latestBankItems, - activeAdminPolicies, - isUserValidated, - isDelegateAccessRestricted, - showDelegateNoAccessModal, - confirmPayment, - } = params; - - // If delegate access is restricted, we should not allow bulk pay with business bank account or bulk pay - if (isDelegateAccessRestricted && 'value' in item && (item.value === CONST.IOU.PAYMENT_TYPE.ELSEWHERE || item.value === CONST.PAYMENT_METHODS.BUSINESS_BANK_ACCOUNT)) { - showDelegateNoAccessModal(); - return; - } - +function handleBulkPayItemSelected( + item: PopoverMenuItem, + triggerKYCFlow: (params: ContinueActionParams) => void, + isAccountLocked: boolean, + showLockedAccountModal: () => void, + policy: OnyxEntry, + latestBankItems: BankAccountMenuItem[] | undefined, + activeAdminPolicies: Policy[], + isUserValidated: boolean | undefined, + confirmPayment?: (paymentType: PaymentMethodType | undefined, additionalData?: Record) => void, +) { const {paymentType, selectedPolicy, shouldSelectPaymentMethod} = getActivePaymentType(item.key, activeAdminPolicies, latestBankItems); // Policy id is also a last payment method so we shouldn't early return here for that case. if (!isValidBulkPayOption(item) && !selectedPolicy) { diff --git a/src/pages/Search/SearchPage.tsx b/src/pages/Search/SearchPage.tsx index a7f431047902..19709ee3f08d 100644 --- a/src/pages/Search/SearchPage.tsx +++ b/src/pages/Search/SearchPage.tsx @@ -6,7 +6,6 @@ import type {ValueOf} from 'type-fest'; import type {DropdownOption} from '@components/ButtonWithDropdownMenu/types'; import ConfirmModal from '@components/ConfirmModal'; import DecisionModal from '@components/DecisionModal'; -import {DelegateNoAccessContext} from '@components/DelegateNoAccessModalProvider'; import DragAndDropConsumer from '@components/DragAndDrop/Consumer'; import DragAndDropProvider from '@components/DragAndDrop/Provider'; import DropZoneUI from '@components/DropZone/DropZoneUI'; @@ -101,7 +100,6 @@ function SearchPage({route}: SearchPageProps) { const styles = useThemeStyles(); const theme = useTheme(); const {isOffline} = useNetwork(); - const {isDelegateAccessRestricted, showDelegateNoAccessModal} = useContext(DelegateNoAccessContext); const {selectedTransactions, clearSelectedTransactions, selectedReports, lastSearchType, setLastSearchType, areAllMatchingItemsSelected, selectAllMatchingItems} = useSearchContext(); const currentUserPersonalDetails = useCurrentUserPersonalDetails(); const isMobileSelectionModeEnabled = useMobileSelectionMode(); @@ -238,11 +236,6 @@ function SearchPage({route}: SearchPageProps) { return; } - if (isDelegateAccessRestricted) { - showDelegateNoAccessModal(); - return; - } - const activeRoute = Navigation.getActiveRoute(); const selectedOptions = selectedReports.length ? selectedReports : Object.values(selectedTransactions); @@ -334,18 +327,7 @@ function SearchPage({route}: SearchPageProps) { clearSelectedTransactions(); }); }, - [ - clearSelectedTransactions, - hash, - isOffline, - isDelegateAccessRestricted, - showDelegateNoAccessModal, - lastPaymentMethods, - selectedReports, - selectedTransactions, - policies, - formatPhoneNumber, - ], + [clearSelectedTransactions, hash, isOffline, lastPaymentMethods, selectedReports, selectedTransactions, policies, formatPhoneNumber], ); // Check if all selected transactions are from the submitter @@ -481,11 +463,6 @@ function SearchPage({route}: SearchPageProps) { return; } - if (isDelegateAccessRestricted) { - showDelegateNoAccessModal(); - return; - } - // Check if any of the selected items have DEW enabled const selectedPolicyIDList = selectedReports.length ? selectedReports.map((report) => report.policyID) @@ -607,11 +584,6 @@ function SearchPage({route}: SearchPageProps) { return; } - if (isDelegateAccessRestricted) { - showDelegateNoAccessModal(); - return; - } - const isDismissed = areAllTransactionsFromSubmitter ? dismissedHoldUseExplanation : dismissedRejectUseExplanation; if (isDismissed) { @@ -779,8 +751,6 @@ function SearchPage({route}: SearchPageProps) { csvExportLayouts, clearSelectedTransactions, beginExportWithTemplate, - isDelegateAccessRestricted, - showDelegateNoAccessModal, dismissedRejectUseExplanation, bulkPayButtonOptions, onBulkPaySelected, diff --git a/src/pages/Search/SearchSelectedNarrow.tsx b/src/pages/Search/SearchSelectedNarrow.tsx index b46795784b9a..ed5ba66a2a5b 100644 --- a/src/pages/Search/SearchSelectedNarrow.tsx +++ b/src/pages/Search/SearchSelectedNarrow.tsx @@ -3,7 +3,6 @@ import React, {useContext, useRef} from 'react'; import {View} from 'react-native'; import ButtonWithDropdownMenu from '@components/ButtonWithDropdownMenu'; import type {DropdownOption} from '@components/ButtonWithDropdownMenu/types'; -import {DelegateNoAccessContext} from '@components/DelegateNoAccessModalProvider'; import KYCWall from '@components/KYCWall'; import {KYCWallContext} from '@components/KYCWall/KYCWallContext'; import type {PaymentMethodType} from '@components/KYCWall/types'; @@ -46,7 +45,6 @@ function SearchSelectedNarrow({options, itemsLength, currentSelectedPolicyID, cu const selectedOptionRef = useRef | null>(null); const {accountID} = useCurrentUserPersonalDetails(); const activeAdminPolicies = getActiveAdminWorkspaces(allPolicies, accountID.toString()).sort((a, b) => localeCompare(a.name || '', b.name || '')); - const {isDelegateAccessRestricted, showDelegateNoAccessModal} = useContext(DelegateNoAccessContext); const handleOnMenuItemPress = (option: DropdownOption) => { if (option?.shouldCloseModalOnSelect) { @@ -77,19 +75,17 @@ function SearchSelectedNarrow({options, itemsLength, currentSelectedPolicyID, cu shouldPopoverUseScrollView={options.length >= CONST.DROPDOWN_SCROLL_THRESHOLD} onOptionSelected={(item) => handleOnMenuItemPress(item)} onSubItemSelected={(subItem) => - handleBulkPayItemSelected({ - item: subItem, + handleBulkPayItemSelected( + subItem, triggerKYCFlow, isAccountLocked, showLockedAccountModal, - policy: currentPolicy, + currentPolicy, latestBankItems, activeAdminPolicies, isUserValidated, - isDelegateAccessRestricted, - showDelegateNoAccessModal, confirmPayment, - }) + ) } success isSplitButton={false}