From 77d1b9569056edceb99a958a859e6c648b4efdee Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Fri, 23 May 2025 17:58:03 +0300 Subject: [PATCH 1/5] removed duplicte actions --- src/components/PromotedActionsBar.tsx | 34 ------- src/pages/ReportDetailsPage.tsx | 133 +------------------------- 2 files changed, 1 insertion(+), 166 deletions(-) diff --git a/src/components/PromotedActionsBar.tsx b/src/components/PromotedActionsBar.tsx index 41be1e79bfc6..154c77b5cd03 100644 --- a/src/components/PromotedActionsBar.tsx +++ b/src/components/PromotedActionsBar.tsx @@ -5,13 +5,10 @@ import useLocalize from '@hooks/useLocalize'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; import {getPinMenuItem, getShareMenuItem} from '@libs/HeaderUtils'; -import isSearchTopmostFullScreenRoute from '@libs/Navigation/helpers/isSearchTopmostFullScreenRoute'; import Navigation from '@libs/Navigation/Navigation'; -import {changeMoneyRequestHoldStatus} from '@libs/ReportUtils'; import {joinRoom, navigateToAndOpenReport, navigateToAndOpenReportWithAccountIDs} from '@userActions/Report'; import {callFunctionIfActionIsAllowed} from '@userActions/Session'; import CONST from '@src/CONST'; -import type {ReportAction} from '@src/types/onyx'; import type OnyxReport from '@src/types/onyx/Report'; import Button from './Button'; import type {ThreeDotsMenuItem} from './HeaderWithBackButton/types'; @@ -27,15 +24,6 @@ type PromotedActionsType = Record P [CONST.PROMOTED_ACTIONS.SHARE]: (report: OnyxReport, backTo?: string) => PromotedAction; } & { [CONST.PROMOTED_ACTIONS.MESSAGE]: (params: {reportID?: string; accountID?: number; login?: string}) => PromotedAction; -} & { - [CONST.PROMOTED_ACTIONS.HOLD]: (params: { - isTextHold: boolean; - reportAction: ReportAction | undefined; - reportID?: string; - isDelegateAccessRestricted: boolean; - setIsNoDelegateAccessMenuVisible: (isVisible: boolean) => void; - currentSearchHash?: number; - }) => PromotedAction; }; const PromotedActions = { @@ -76,28 +64,6 @@ const PromotedActions = { } }, }), - hold: ({isTextHold, reportAction, isDelegateAccessRestricted, setIsNoDelegateAccessMenuVisible, currentSearchHash}) => ({ - key: CONST.PROMOTED_ACTIONS.HOLD, - icon: Expensicons.Stopwatch, - translationKey: `iou.${isTextHold ? 'hold' : 'unhold'}`, - onSelected: () => { - if (isDelegateAccessRestricted) { - setIsNoDelegateAccessMenuVisible(true); // Show the menu - return; - } - - if (!isTextHold) { - Navigation.goBack(); - } - - if (!isSearchTopmostFullScreenRoute()) { - changeMoneyRequestHoldStatus(reportAction); - return; - } - - changeMoneyRequestHoldStatus(reportAction, currentSearchHash); - }, - }), } satisfies PromotedActionsType; type PromotedActionsBarProps = { diff --git a/src/pages/ReportDetailsPage.tsx b/src/pages/ReportDetailsPage.tsx index 48ea2c9d785a..be69011a9c1f 100644 --- a/src/pages/ReportDetailsPage.tsx +++ b/src/pages/ReportDetailsPage.tsx @@ -26,10 +26,8 @@ import PromotedActionsBar, {PromotedActions} from '@components/PromotedActionsBa import RoomHeaderAvatars from '@components/RoomHeaderAvatars'; import ScreenWrapper from '@components/ScreenWrapper'; import ScrollView from '@components/ScrollView'; -import {useSearchContext} from '@components/Search/SearchContext'; import Text from '@components/Text'; import TextWithCopy from '@components/TextWithCopy'; -import useDelegateUserDetails from '@hooks/useDelegateUserDetails'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; import usePaginatedReportActions from '@hooks/usePaginatedReportActions'; @@ -48,7 +46,6 @@ import { canDeleteCardTransactionByLiabilityType, canDeleteTransaction, canEditReportDescription as canEditReportDescriptionUtil, - canHoldUnholdReportAction as canHoldUnholdReportActionUtil, canJoinChat, canLeaveChat, canWriteInReport, @@ -74,7 +71,6 @@ import { isConciergeChatReport, isDefaultRoom as isDefaultRoomUtil, isExpenseReport as isExpenseReportUtil, - isExported, isFinancialReportsForBusinesses as isFinancialReportsForBusinessesUtil, isGroupChat as isGroupChatUtil, isHiddenForCurrentUser, @@ -95,15 +91,12 @@ import { isUserCreatedPolicyRoom as isUserCreatedPolicyRoomUtil, navigateBackOnDeleteTransaction, navigateToPrivateNotes, - reportTransactionsSelector, shouldDisableRename as shouldDisableRenameUtil, shouldUseFullTitleToDisplay, } from '@libs/ReportUtils'; import StringUtils from '@libs/StringUtils'; import { - canCancelPayment, cancelPayment as cancelPaymentAction, - canUnapproveIOU, deleteMoneyRequest, deleteTrackExpense, getNavigationUrlAfterTrackExpenseDelete, @@ -113,7 +106,6 @@ import { import { clearAvatarErrors, clearPolicyRoomNameErrors, - exportReportToCSV, getReportPrivateNote, hasErrorInPrivateNotes, leaveGroupChat, @@ -172,10 +164,8 @@ function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDeta }); const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID}`, {canBeMissing: false}); - const [parentReportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.parentReportID}`, {canBeMissing: true}); const {reportActions} = usePaginatedReportActions(report.reportID); - const {currentSearchHash} = useSearchContext(); // We need to use isSmallScreenWidth instead of shouldUseNarrowLayout to apply the correct modal type for the decision modal // eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth @@ -188,11 +178,6 @@ function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDeta const [isDebugModeEnabled] = useOnyx(ONYXKEYS.ACCOUNT, {selector: (account) => !!account?.isDebugModeEnabled, canBeMissing: false}); const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {canBeMissing: false}); const [session] = useOnyx(ONYXKEYS.SESSION, {canBeMissing: false}); - const [transactions] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION, { - selector: (_transactions) => reportTransactionsSelector(_transactions, report.reportID), - initialValue: [], - canBeMissing: true, - }); const {removeTransaction} = useMoneyRequestReportContext(); @@ -263,13 +248,6 @@ function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDeta caseID = CASES.DEFAULT; } - const transactionIDList = useMemo(() => { - if (caseID !== CASES.MONEY_REPORT || !transactions) { - return []; - } - return transactions.map((transaction) => transaction.transactionID); - }, [caseID, transactions]); - // Get the active chat members by filtering out the pending members with delete action const activeChatMembers = participants.flatMap((accountID) => { const pendingMember = reportMetadata?.pendingChatMembers?.findLast((member) => member.accountID === accountID.toString()); @@ -304,8 +282,6 @@ function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDeta return report; }, [caseID, parentReport, report]); - const moneyRequestAction = transactionThreadReportID ? requestParentReportAction : parentReportAction; - const canActionTask = canActionTaskAction(report, session?.accountID ?? CONST.DEFAULT_NUMBER_ID); const shouldShowTaskDeleteButton = isTaskReport && !isCanceledTaskReport && canWriteInReport(report) && report.stateNum !== CONST.REPORT.STATE_NUM.APPROVED && !isClosedReport(report) && canModifyTask && canActionTask; @@ -342,22 +318,8 @@ function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDeta }); }, [isPolicyEmployee, isPolicyExpenseChat, isRootGroupChat, report.reportID, report.visibility]); - const [moneyRequestReportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${moneyRequestReport?.reportID}`, {canBeMissing: true}); - const isMoneyRequestExported = isExported(moneyRequestReportActions); - const {isDelegateAccessRestricted} = useDelegateUserDetails(); const [isNoDelegateAccessMenuVisible, setIsNoDelegateAccessMenuVisible] = useState(false); - const unapproveExpenseReportOrShowModal = useCallback(() => { - if (isDelegateAccessRestricted) { - setIsNoDelegateAccessMenuVisible(true); - } else if (isMoneyRequestExported) { - setIsUnapproveModalVisible(true); - return; - } - Navigation.goBack(backTo); - unapproveExpenseReport(moneyRequestReport); - }, [isDelegateAccessRestricted, isMoneyRequestExported, backTo, moneyRequestReport]); - const shouldShowLeaveButton = canLeaveChat(report, policy); const shouldShowGoToWorkspace = shouldShowPolicy(policy, false, session?.email) && !policy?.isJoinRequestPending; @@ -380,7 +342,6 @@ function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDeta const shouldShowNotificationPref = !isMoneyRequestReport && !isHiddenForCurrentUser(report); const shouldShowWriteCapability = !isMoneyRequestReport; const shouldShowMenuItem = shouldShowNotificationPref || shouldShowWriteCapability || (!!report?.visibility && report.chatType !== CONST.REPORT.CHAT_TYPE.INVOICE); - const shouldShowCancelPaymentButton = caseID === CASES.MONEY_REPORT && canCancelPayment(moneyRequestReport, session); const [chatReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${moneyRequestReport?.chatReportID}`, {canBeMissing: true}); const cancelPayment = useCallback(() => { @@ -522,57 +483,6 @@ function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDeta } } - if (!canUseTableReportView && shouldShowCancelPaymentButton) { - items.push({ - key: CONST.REPORT_DETAILS_MENU_ITEM.CANCEL_PAYMENT, - icon: Expensicons.Trashcan, - translationKey: 'iou.cancelPayment', - isAnonymousAction: false, - action: () => setIsConfirmModalVisible(true), - }); - } - - if (caseID === CASES.MONEY_REPORT) { - items.push({ - key: CONST.REPORT_DETAILS_MENU_ITEM.DOWNLOAD_CSV, - translationKey: 'common.downloadAsCSV', - icon: Expensicons.Table, - isAnonymousAction: false, - action: () => { - if (isOffline) { - setOfflineModalVisible(true); - return; - } - - exportReportToCSV({reportID: report.reportID, transactionIDList}, () => { - setDownloadErrorModalVisible(true); - }); - }, - }); - } - - if (policy && connectedIntegration && isPolicyAdmin && !isSingleTransactionView && isExpenseReport) { - items.push({ - key: CONST.REPORT_DETAILS_MENU_ITEM.EXPORT, - translationKey: 'common.export', - icon: Expensicons.Export, - isAnonymousAction: false, - action: () => { - Navigation.navigate(ROUTES.REPORT_WITH_ID_DETAILS_EXPORT.getRoute(report?.reportID, connectedIntegration, backTo)); - }, - }); - } - - if (!canUseTableReportView && canUnapproveIOU(report, policy)) { - items.push({ - key: CONST.REPORT_DETAILS_MENU_ITEM.UNAPPROVE, - icon: Expensicons.CircularArrowBackwards, - translationKey: 'iou.unapprove', - isAnonymousAction: false, - action: () => unapproveExpenseReportOrShowModal(), - }); - } - if (shouldShowGoToWorkspace) { items.push({ key: CONST.REPORT_DETAILS_MENU_ITEM.GO_TO_WORKSPACE, @@ -637,14 +547,6 @@ function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDeta isInvoiceReport, isTaskReport, isCanceledTaskReport, - canUseTableReportView, - shouldShowCancelPaymentButton, - caseID, - policy, - connectedIntegration, - isPolicyAdmin, - isSingleTransactionView, - isExpenseReport, shouldShowGoToWorkspace, shouldShowLeaveButton, isDebugModeEnabled, @@ -657,9 +559,6 @@ function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDeta session, canModifyTask, canActionTask, - isOffline, - transactionIDList, - unapproveExpenseReportOrShowModal, isRootGroupChat, leaveChat, ]); @@ -735,11 +634,6 @@ function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDeta ); }, [report, icons, isMoneyRequestReport, isInvoiceReport, isGroupChat, isThread, styles]); - const canHoldUnholdReportAction = canHoldUnholdReportActionUtil(moneyRequestAction); - const shouldShowHoldAction = - caseID !== CASES.DEFAULT && - (canHoldUnholdReportAction.canHoldRequest || canHoldUnholdReportAction.canUnholdRequest) && - !isArchivedNonExpenseReport(transactionThreadReportID ? report : parentReport, transactionThreadReportID ? reportNameValuePairs : parentReportNameValuePairs); const canJoin = canJoinChat(report, parentReportAction, policy, reportNameValuePairs); const promotedActions = useMemo(() => { @@ -749,19 +643,6 @@ function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDeta result.push(PromotedActions.join(report)); } - if (!canUseTableReportView && isExpenseReport && shouldShowHoldAction) { - result.push( - PromotedActions.hold({ - isTextHold: canHoldUnholdReportAction.canHoldRequest, - reportAction: moneyRequestAction, - reportID: transactionThreadReportID ? report.reportID : moneyRequestAction?.childReportID, - isDelegateAccessRestricted, - setIsNoDelegateAccessMenuVisible, - currentSearchHash, - }), - ); - } - if (report) { result.push(PromotedActions.pin(report)); } @@ -769,19 +650,7 @@ function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDeta result.push(PromotedActions.share(report, backTo)); return result; - }, [ - canJoin, - canUseTableReportView, - isExpenseReport, - shouldShowHoldAction, - report, - backTo, - canHoldUnholdReportAction.canHoldRequest, - moneyRequestAction, - transactionThreadReportID, - isDelegateAccessRestricted, - currentSearchHash, - ]); + }, [canJoin, report, backTo]); const nameSectionExpenseIOU = ( From 3a02dba6ad7a3467bb0a2499bb6fdfec920fa983 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Fri, 23 May 2025 23:17:34 +0300 Subject: [PATCH 2/5] fix errors --- src/libs/ReportUtils.ts | 6 +- src/libs/actions/IOU.ts | 60 +---------- tests/unit/PromotedActionsBarTest.ts | 142 --------------------------- 3 files changed, 5 insertions(+), 203 deletions(-) delete mode 100644 tests/unit/PromotedActionsBarTest.ts diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index ca8836d0ba65..f84c28534902 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -4026,7 +4026,7 @@ function canHoldUnholdReportAction(reportAction: OnyxInputOrEntry) return {canHoldRequest, canUnholdRequest}; } -const changeMoneyRequestHoldStatus = (reportAction: OnyxEntry, searchHash?: number): void => { +const changeMoneyRequestHoldStatus = (reportAction: OnyxEntry): void => { if (!isMoneyRequestAction(reportAction)) { return; } @@ -4049,10 +4049,10 @@ const changeMoneyRequestHoldStatus = (reportAction: OnyxEntry, sea const policy = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${moneyRequestReport.policyID}`] ?? null; if (isOnHold) { - unholdRequest(transactionID, reportAction.childReportID, searchHash); + unholdRequest(transactionID, reportAction.childReportID); } else { const activeRoute = encodeURIComponent(Navigation.getActiveRoute()); - Navigation.navigate(ROUTES.MONEY_REQUEST_HOLD_REASON.getRoute(policy?.type ?? CONST.POLICY.TYPE.PERSONAL, transactionID, reportAction.childReportID, activeRoute, searchHash)); + Navigation.navigate(ROUTES.MONEY_REQUEST_HOLD_REASON.getRoute(policy?.type ?? CONST.POLICY.TYPE.PERSONAL, transactionID, reportAction.childReportID, activeRoute)); } }; diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index bd852a9ea4fb..447b64c76878 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -10255,7 +10255,7 @@ function adjustRemainingSplitShares(transaction: NonNullable>>, - }); - failureData.push({ - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.SNAPSHOT}${searchHash}`, - value: { - data: { - [`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`]: { - canHold: true, - canUnhold: false, - }, - }, - } as Record>>, - }); - } - API.write( 'HoldRequest', { @@ -10406,7 +10378,7 @@ function putOnHold(transactionID: string, comment: string, reportID: string, sea /** * Remove expense from HOLD */ -function unholdRequest(transactionID: string, reportID: string, searchHash?: number) { +function unholdRequest(transactionID: string, reportID: string) { const createdReportAction = buildOptimisticUnHoldReportAction(); const transactionViolations = allTransactionViolations[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`]; const transaction = allTransactions[`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`]; @@ -10502,34 +10474,6 @@ function unholdRequest(transactionID: string, reportID: string, searchHash?: num }, ]; - // If we are un-holding from the search page, we optimistically update the snapshot data that search uses so that it is kept in sync - if (searchHash) { - optimisticData.push({ - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.SNAPSHOT}${searchHash}`, - value: { - data: { - [`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`]: { - canHold: true, - canUnhold: false, - }, - }, - } as Record>>, - }); - failureData.push({ - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.SNAPSHOT}${searchHash}`, - value: { - data: { - [`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`]: { - canHold: false, - canUnhold: true, - }, - }, - } as Record>>, - }); - } - API.write( 'UnHoldRequest', { diff --git a/tests/unit/PromotedActionsBarTest.ts b/tests/unit/PromotedActionsBarTest.ts deleted file mode 100644 index 97dfa2e8bd35..000000000000 --- a/tests/unit/PromotedActionsBarTest.ts +++ /dev/null @@ -1,142 +0,0 @@ -import Onyx from 'react-native-onyx'; -import {PromotedActions} from '@components/PromotedActionsBar'; -import OnyxUpdateManager from '@libs/actions/OnyxUpdateManager'; -import isSearchTopmostFullScreenRoute from '@libs/Navigation/helpers/isSearchTopmostFullScreenRoute'; -import CONST from '@src/CONST'; -import ONYXKEYS from '@src/ONYXKEYS'; -import type {ReportAction, Transaction} from '@src/types/onyx'; -import createRandomReportAction from '../utils/collections/reportActions'; -import createRandomTransaction from '../utils/collections/transaction'; -import {getGlobalFetchMock} from '../utils/TestHelper'; -import waitForBatchedUpdates from '../utils/waitForBatchedUpdates'; - -jest.mock('@libs/Navigation/helpers/isSearchTopmostFullScreenRoute', () => jest.fn()); - -const mockedIsSearchTopmostFullScreenRoute = isSearchTopmostFullScreenRoute as jest.MockedFunction; - -OnyxUpdateManager(); -describe('PromotedActionsBar', () => { - beforeAll(() => { - Onyx.init({ - keys: ONYXKEYS, - }); - }); - - beforeEach(() => { - global.fetch = getGlobalFetchMock(); - mockedIsSearchTopmostFullScreenRoute.mockReset(); - return Onyx.clear().then(waitForBatchedUpdates); - }); - - describe('hold', () => { - it('should not optimistically update the search snapshot if the topmost central pane is not search', async () => { - // Given a held transaction - const IOUReportID = '1'; - const IOUTransactionID = '2'; - const searchHash = 2; - const reportAction: ReportAction<'IOU'> = { - ...createRandomReportAction(0), - actionName: CONST.REPORT.ACTIONS.TYPE.IOU, - originalMessage: { - amount: 100, - currency: 'USD', - type: 'create', - IOUReportID, - IOUTransactionID, - }, - message: [], - previousMessage: [], - }; - const transaction: Transaction = { - ...createRandomTransaction(Number(IOUTransactionID)), - comment: { - hold: '1', - }, - }; - await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${IOUReportID}`, { - reportID: IOUReportID, - }); - await Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION}${IOUTransactionID}`, transaction); - - // When the user unheld the transaction not from the search central pane - PromotedActions.hold({ - isTextHold: false, - reportAction, - reportID: '1', - isDelegateAccessRestricted: false, - setIsNoDelegateAccessMenuVisible: () => {}, - currentSearchHash: searchHash, - }).onSelected(); - - await waitForBatchedUpdates(); - - // Then the search snapshot should not be updated optimistically - await new Promise((resolve) => { - const connection = Onyx.connect({ - key: `${ONYXKEYS.COLLECTION.SNAPSHOT}${searchHash}`, - callback: (snapshot) => { - Onyx.disconnect(connection); - expect(snapshot).toBeUndefined(); - resolve(); - }, - }); - }); - }); - - it('should optimistically update the search snapshot if the topmost central pane is search', async () => { - // Given a held transaction - const IOUReportID = '1'; - const IOUTransactionID = '2'; - const searchHash = 2; - const reportAction: ReportAction<'IOU'> = { - ...createRandomReportAction(0), - childReportID: '3', - actionName: CONST.REPORT.ACTIONS.TYPE.IOU, - originalMessage: { - amount: 100, - currency: 'USD', - type: 'create', - IOUReportID, - IOUTransactionID, - }, - message: [], - previousMessage: [], - }; - const transaction: Transaction = { - ...createRandomTransaction(Number(IOUTransactionID)), - comment: { - hold: '1', - }, - }; - await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${IOUReportID}`, { - reportID: IOUReportID, - }); - await Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION}${IOUTransactionID}`, transaction); - - // When the user unheld the transaction from the search central pane - mockedIsSearchTopmostFullScreenRoute.mockReturnValueOnce(true); - PromotedActions.hold({ - isTextHold: false, - reportAction, - reportID: '1', - isDelegateAccessRestricted: false, - setIsNoDelegateAccessMenuVisible: () => {}, - currentSearchHash: searchHash, - }).onSelected(); - - await waitForBatchedUpdates(); - - // Then the search snapshot should be updated optimistically - await new Promise((resolve) => { - const connection = Onyx.connect({ - key: `${ONYXKEYS.COLLECTION.SNAPSHOT}${searchHash}`, - callback: (snapshot) => { - Onyx.disconnect(connection); - expect(snapshot).not.toBeUndefined(); - resolve(); - }, - }); - }); - }); - }); -}); From d7d4c9ed05fa179f32170ec83e36cc5e1244bb3e Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Fri, 23 May 2025 23:22:25 +0300 Subject: [PATCH 3/5] Revert "fix errors" This reverts commit 3a02dba6ad7a3467bb0a2499bb6fdfec920fa983. --- src/libs/ReportUtils.ts | 6 +- src/libs/actions/IOU.ts | 60 ++++++++++- tests/unit/PromotedActionsBarTest.ts | 142 +++++++++++++++++++++++++++ 3 files changed, 203 insertions(+), 5 deletions(-) create mode 100644 tests/unit/PromotedActionsBarTest.ts diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index f84c28534902..ca8836d0ba65 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -4026,7 +4026,7 @@ function canHoldUnholdReportAction(reportAction: OnyxInputOrEntry) return {canHoldRequest, canUnholdRequest}; } -const changeMoneyRequestHoldStatus = (reportAction: OnyxEntry): void => { +const changeMoneyRequestHoldStatus = (reportAction: OnyxEntry, searchHash?: number): void => { if (!isMoneyRequestAction(reportAction)) { return; } @@ -4049,10 +4049,10 @@ const changeMoneyRequestHoldStatus = (reportAction: OnyxEntry): vo const policy = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${moneyRequestReport.policyID}`] ?? null; if (isOnHold) { - unholdRequest(transactionID, reportAction.childReportID); + unholdRequest(transactionID, reportAction.childReportID, searchHash); } else { const activeRoute = encodeURIComponent(Navigation.getActiveRoute()); - Navigation.navigate(ROUTES.MONEY_REQUEST_HOLD_REASON.getRoute(policy?.type ?? CONST.POLICY.TYPE.PERSONAL, transactionID, reportAction.childReportID, activeRoute)); + Navigation.navigate(ROUTES.MONEY_REQUEST_HOLD_REASON.getRoute(policy?.type ?? CONST.POLICY.TYPE.PERSONAL, transactionID, reportAction.childReportID, activeRoute, searchHash)); } }; diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 447b64c76878..bd852a9ea4fb 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -10255,7 +10255,7 @@ function adjustRemainingSplitShares(transaction: NonNullable>>, + }); + failureData.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.SNAPSHOT}${searchHash}`, + value: { + data: { + [`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`]: { + canHold: true, + canUnhold: false, + }, + }, + } as Record>>, + }); + } + API.write( 'HoldRequest', { @@ -10378,7 +10406,7 @@ function putOnHold(transactionID: string, comment: string, reportID: string) { /** * Remove expense from HOLD */ -function unholdRequest(transactionID: string, reportID: string) { +function unholdRequest(transactionID: string, reportID: string, searchHash?: number) { const createdReportAction = buildOptimisticUnHoldReportAction(); const transactionViolations = allTransactionViolations[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`]; const transaction = allTransactions[`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`]; @@ -10474,6 +10502,34 @@ function unholdRequest(transactionID: string, reportID: string) { }, ]; + // If we are un-holding from the search page, we optimistically update the snapshot data that search uses so that it is kept in sync + if (searchHash) { + optimisticData.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.SNAPSHOT}${searchHash}`, + value: { + data: { + [`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`]: { + canHold: true, + canUnhold: false, + }, + }, + } as Record>>, + }); + failureData.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.SNAPSHOT}${searchHash}`, + value: { + data: { + [`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`]: { + canHold: false, + canUnhold: true, + }, + }, + } as Record>>, + }); + } + API.write( 'UnHoldRequest', { diff --git a/tests/unit/PromotedActionsBarTest.ts b/tests/unit/PromotedActionsBarTest.ts new file mode 100644 index 000000000000..97dfa2e8bd35 --- /dev/null +++ b/tests/unit/PromotedActionsBarTest.ts @@ -0,0 +1,142 @@ +import Onyx from 'react-native-onyx'; +import {PromotedActions} from '@components/PromotedActionsBar'; +import OnyxUpdateManager from '@libs/actions/OnyxUpdateManager'; +import isSearchTopmostFullScreenRoute from '@libs/Navigation/helpers/isSearchTopmostFullScreenRoute'; +import CONST from '@src/CONST'; +import ONYXKEYS from '@src/ONYXKEYS'; +import type {ReportAction, Transaction} from '@src/types/onyx'; +import createRandomReportAction from '../utils/collections/reportActions'; +import createRandomTransaction from '../utils/collections/transaction'; +import {getGlobalFetchMock} from '../utils/TestHelper'; +import waitForBatchedUpdates from '../utils/waitForBatchedUpdates'; + +jest.mock('@libs/Navigation/helpers/isSearchTopmostFullScreenRoute', () => jest.fn()); + +const mockedIsSearchTopmostFullScreenRoute = isSearchTopmostFullScreenRoute as jest.MockedFunction; + +OnyxUpdateManager(); +describe('PromotedActionsBar', () => { + beforeAll(() => { + Onyx.init({ + keys: ONYXKEYS, + }); + }); + + beforeEach(() => { + global.fetch = getGlobalFetchMock(); + mockedIsSearchTopmostFullScreenRoute.mockReset(); + return Onyx.clear().then(waitForBatchedUpdates); + }); + + describe('hold', () => { + it('should not optimistically update the search snapshot if the topmost central pane is not search', async () => { + // Given a held transaction + const IOUReportID = '1'; + const IOUTransactionID = '2'; + const searchHash = 2; + const reportAction: ReportAction<'IOU'> = { + ...createRandomReportAction(0), + actionName: CONST.REPORT.ACTIONS.TYPE.IOU, + originalMessage: { + amount: 100, + currency: 'USD', + type: 'create', + IOUReportID, + IOUTransactionID, + }, + message: [], + previousMessage: [], + }; + const transaction: Transaction = { + ...createRandomTransaction(Number(IOUTransactionID)), + comment: { + hold: '1', + }, + }; + await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${IOUReportID}`, { + reportID: IOUReportID, + }); + await Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION}${IOUTransactionID}`, transaction); + + // When the user unheld the transaction not from the search central pane + PromotedActions.hold({ + isTextHold: false, + reportAction, + reportID: '1', + isDelegateAccessRestricted: false, + setIsNoDelegateAccessMenuVisible: () => {}, + currentSearchHash: searchHash, + }).onSelected(); + + await waitForBatchedUpdates(); + + // Then the search snapshot should not be updated optimistically + await new Promise((resolve) => { + const connection = Onyx.connect({ + key: `${ONYXKEYS.COLLECTION.SNAPSHOT}${searchHash}`, + callback: (snapshot) => { + Onyx.disconnect(connection); + expect(snapshot).toBeUndefined(); + resolve(); + }, + }); + }); + }); + + it('should optimistically update the search snapshot if the topmost central pane is search', async () => { + // Given a held transaction + const IOUReportID = '1'; + const IOUTransactionID = '2'; + const searchHash = 2; + const reportAction: ReportAction<'IOU'> = { + ...createRandomReportAction(0), + childReportID: '3', + actionName: CONST.REPORT.ACTIONS.TYPE.IOU, + originalMessage: { + amount: 100, + currency: 'USD', + type: 'create', + IOUReportID, + IOUTransactionID, + }, + message: [], + previousMessage: [], + }; + const transaction: Transaction = { + ...createRandomTransaction(Number(IOUTransactionID)), + comment: { + hold: '1', + }, + }; + await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${IOUReportID}`, { + reportID: IOUReportID, + }); + await Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION}${IOUTransactionID}`, transaction); + + // When the user unheld the transaction from the search central pane + mockedIsSearchTopmostFullScreenRoute.mockReturnValueOnce(true); + PromotedActions.hold({ + isTextHold: false, + reportAction, + reportID: '1', + isDelegateAccessRestricted: false, + setIsNoDelegateAccessMenuVisible: () => {}, + currentSearchHash: searchHash, + }).onSelected(); + + await waitForBatchedUpdates(); + + // Then the search snapshot should be updated optimistically + await new Promise((resolve) => { + const connection = Onyx.connect({ + key: `${ONYXKEYS.COLLECTION.SNAPSHOT}${searchHash}`, + callback: (snapshot) => { + Onyx.disconnect(connection); + expect(snapshot).not.toBeUndefined(); + resolve(); + }, + }); + }); + }); + }); +}); From 83e3a44f92ec7b4738596349ce2ba2c618c17588 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Fri, 23 May 2025 23:34:52 +0300 Subject: [PATCH 4/5] fix ts --- src/libs/ReportUtils.ts | 6 +- src/libs/actions/IOU.ts | 30 +----- tests/unit/PromotedActionsBarTest.ts | 142 --------------------------- 3 files changed, 4 insertions(+), 174 deletions(-) delete mode 100644 tests/unit/PromotedActionsBarTest.ts diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index ca8836d0ba65..f84c28534902 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -4026,7 +4026,7 @@ function canHoldUnholdReportAction(reportAction: OnyxInputOrEntry) return {canHoldRequest, canUnholdRequest}; } -const changeMoneyRequestHoldStatus = (reportAction: OnyxEntry, searchHash?: number): void => { +const changeMoneyRequestHoldStatus = (reportAction: OnyxEntry): void => { if (!isMoneyRequestAction(reportAction)) { return; } @@ -4049,10 +4049,10 @@ const changeMoneyRequestHoldStatus = (reportAction: OnyxEntry, sea const policy = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${moneyRequestReport.policyID}`] ?? null; if (isOnHold) { - unholdRequest(transactionID, reportAction.childReportID, searchHash); + unholdRequest(transactionID, reportAction.childReportID); } else { const activeRoute = encodeURIComponent(Navigation.getActiveRoute()); - Navigation.navigate(ROUTES.MONEY_REQUEST_HOLD_REASON.getRoute(policy?.type ?? CONST.POLICY.TYPE.PERSONAL, transactionID, reportAction.childReportID, activeRoute, searchHash)); + Navigation.navigate(ROUTES.MONEY_REQUEST_HOLD_REASON.getRoute(policy?.type ?? CONST.POLICY.TYPE.PERSONAL, transactionID, reportAction.childReportID, activeRoute)); } }; diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index bd852a9ea4fb..14ce42d5805e 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -10406,7 +10406,7 @@ function putOnHold(transactionID: string, comment: string, reportID: string, sea /** * Remove expense from HOLD */ -function unholdRequest(transactionID: string, reportID: string, searchHash?: number) { +function unholdRequest(transactionID: string, reportID: string) { const createdReportAction = buildOptimisticUnHoldReportAction(); const transactionViolations = allTransactionViolations[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`]; const transaction = allTransactions[`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`]; @@ -10502,34 +10502,6 @@ function unholdRequest(transactionID: string, reportID: string, searchHash?: num }, ]; - // If we are un-holding from the search page, we optimistically update the snapshot data that search uses so that it is kept in sync - if (searchHash) { - optimisticData.push({ - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.SNAPSHOT}${searchHash}`, - value: { - data: { - [`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`]: { - canHold: true, - canUnhold: false, - }, - }, - } as Record>>, - }); - failureData.push({ - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.SNAPSHOT}${searchHash}`, - value: { - data: { - [`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`]: { - canHold: false, - canUnhold: true, - }, - }, - } as Record>>, - }); - } - API.write( 'UnHoldRequest', { diff --git a/tests/unit/PromotedActionsBarTest.ts b/tests/unit/PromotedActionsBarTest.ts deleted file mode 100644 index 97dfa2e8bd35..000000000000 --- a/tests/unit/PromotedActionsBarTest.ts +++ /dev/null @@ -1,142 +0,0 @@ -import Onyx from 'react-native-onyx'; -import {PromotedActions} from '@components/PromotedActionsBar'; -import OnyxUpdateManager from '@libs/actions/OnyxUpdateManager'; -import isSearchTopmostFullScreenRoute from '@libs/Navigation/helpers/isSearchTopmostFullScreenRoute'; -import CONST from '@src/CONST'; -import ONYXKEYS from '@src/ONYXKEYS'; -import type {ReportAction, Transaction} from '@src/types/onyx'; -import createRandomReportAction from '../utils/collections/reportActions'; -import createRandomTransaction from '../utils/collections/transaction'; -import {getGlobalFetchMock} from '../utils/TestHelper'; -import waitForBatchedUpdates from '../utils/waitForBatchedUpdates'; - -jest.mock('@libs/Navigation/helpers/isSearchTopmostFullScreenRoute', () => jest.fn()); - -const mockedIsSearchTopmostFullScreenRoute = isSearchTopmostFullScreenRoute as jest.MockedFunction; - -OnyxUpdateManager(); -describe('PromotedActionsBar', () => { - beforeAll(() => { - Onyx.init({ - keys: ONYXKEYS, - }); - }); - - beforeEach(() => { - global.fetch = getGlobalFetchMock(); - mockedIsSearchTopmostFullScreenRoute.mockReset(); - return Onyx.clear().then(waitForBatchedUpdates); - }); - - describe('hold', () => { - it('should not optimistically update the search snapshot if the topmost central pane is not search', async () => { - // Given a held transaction - const IOUReportID = '1'; - const IOUTransactionID = '2'; - const searchHash = 2; - const reportAction: ReportAction<'IOU'> = { - ...createRandomReportAction(0), - actionName: CONST.REPORT.ACTIONS.TYPE.IOU, - originalMessage: { - amount: 100, - currency: 'USD', - type: 'create', - IOUReportID, - IOUTransactionID, - }, - message: [], - previousMessage: [], - }; - const transaction: Transaction = { - ...createRandomTransaction(Number(IOUTransactionID)), - comment: { - hold: '1', - }, - }; - await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${IOUReportID}`, { - reportID: IOUReportID, - }); - await Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION}${IOUTransactionID}`, transaction); - - // When the user unheld the transaction not from the search central pane - PromotedActions.hold({ - isTextHold: false, - reportAction, - reportID: '1', - isDelegateAccessRestricted: false, - setIsNoDelegateAccessMenuVisible: () => {}, - currentSearchHash: searchHash, - }).onSelected(); - - await waitForBatchedUpdates(); - - // Then the search snapshot should not be updated optimistically - await new Promise((resolve) => { - const connection = Onyx.connect({ - key: `${ONYXKEYS.COLLECTION.SNAPSHOT}${searchHash}`, - callback: (snapshot) => { - Onyx.disconnect(connection); - expect(snapshot).toBeUndefined(); - resolve(); - }, - }); - }); - }); - - it('should optimistically update the search snapshot if the topmost central pane is search', async () => { - // Given a held transaction - const IOUReportID = '1'; - const IOUTransactionID = '2'; - const searchHash = 2; - const reportAction: ReportAction<'IOU'> = { - ...createRandomReportAction(0), - childReportID: '3', - actionName: CONST.REPORT.ACTIONS.TYPE.IOU, - originalMessage: { - amount: 100, - currency: 'USD', - type: 'create', - IOUReportID, - IOUTransactionID, - }, - message: [], - previousMessage: [], - }; - const transaction: Transaction = { - ...createRandomTransaction(Number(IOUTransactionID)), - comment: { - hold: '1', - }, - }; - await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${IOUReportID}`, { - reportID: IOUReportID, - }); - await Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION}${IOUTransactionID}`, transaction); - - // When the user unheld the transaction from the search central pane - mockedIsSearchTopmostFullScreenRoute.mockReturnValueOnce(true); - PromotedActions.hold({ - isTextHold: false, - reportAction, - reportID: '1', - isDelegateAccessRestricted: false, - setIsNoDelegateAccessMenuVisible: () => {}, - currentSearchHash: searchHash, - }).onSelected(); - - await waitForBatchedUpdates(); - - // Then the search snapshot should be updated optimistically - await new Promise((resolve) => { - const connection = Onyx.connect({ - key: `${ONYXKEYS.COLLECTION.SNAPSHOT}${searchHash}`, - callback: (snapshot) => { - Onyx.disconnect(connection); - expect(snapshot).not.toBeUndefined(); - resolve(); - }, - }); - }); - }); - }); -}); From d262d19f6539c986a6954d678ff42d1feb2a28a9 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Tue, 27 May 2025 15:37:30 +0300 Subject: [PATCH 5/5] Removed unnecessary code --- src/pages/ReportDetailsPage.tsx | 97 +-------------------------------- 1 file changed, 2 insertions(+), 95 deletions(-) diff --git a/src/pages/ReportDetailsPage.tsx b/src/pages/ReportDetailsPage.tsx index be69011a9c1f..49fe12b15d52 100644 --- a/src/pages/ReportDetailsPage.tsx +++ b/src/pages/ReportDetailsPage.tsx @@ -7,8 +7,6 @@ import type {ValueOf} from 'type-fest'; import AvatarWithImagePicker from '@components/AvatarWithImagePicker'; import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView'; import ConfirmModal from '@components/ConfirmModal'; -import DecisionModal from '@components/DecisionModal'; -import DelegateNoAccessModal from '@components/DelegateNoAccessModal'; import DisplayNames from '@components/DisplayNames'; import FixedFooter from '@components/FixedFooter'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; @@ -26,13 +24,10 @@ import PromotedActionsBar, {PromotedActions} from '@components/PromotedActionsBa import RoomHeaderAvatars from '@components/RoomHeaderAvatars'; import ScreenWrapper from '@components/ScreenWrapper'; import ScrollView from '@components/ScrollView'; -import Text from '@components/Text'; import TextWithCopy from '@components/TextWithCopy'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; import usePaginatedReportActions from '@hooks/usePaginatedReportActions'; -import usePermissions from '@hooks/usePermissions'; -import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useThemeStyles from '@hooks/useThemeStyles'; import getBase62ReportID from '@libs/getBase62ReportID'; import Navigation from '@libs/Navigation/Navigation'; @@ -40,7 +35,7 @@ import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavig import type {ReportDetailsNavigatorParamList} from '@libs/Navigation/types'; import {getPersonalDetailsForAccountIDs} from '@libs/OptionsListUtils'; import Parser from '@libs/Parser'; -import {getConnectedIntegration, isPolicyAdmin as isPolicyAdminUtil, isPolicyEmployee as isPolicyEmployeeUtil, shouldShowPolicy} from '@libs/PolicyUtils'; +import {isPolicyAdmin as isPolicyAdminUtil, isPolicyEmployee as isPolicyEmployeeUtil, shouldShowPolicy} from '@libs/PolicyUtils'; import {getOneTransactionThreadReportID, getOriginalMessage, getTrackExpenseActionableWhisper, isDeletedAction, isMoneyRequestAction, isTrackExpenseAction} from '@libs/ReportActionsUtils'; import { canDeleteCardTransactionByLiabilityType, @@ -95,14 +90,7 @@ import { shouldUseFullTitleToDisplay, } from '@libs/ReportUtils'; import StringUtils from '@libs/StringUtils'; -import { - cancelPayment as cancelPaymentAction, - deleteMoneyRequest, - deleteTrackExpense, - getNavigationUrlAfterTrackExpenseDelete, - getNavigationUrlOnMoneyRequestDelete, - unapproveExpenseReport, -} from '@userActions/IOU'; +import {deleteMoneyRequest, deleteTrackExpense, getNavigationUrlAfterTrackExpenseDelete, getNavigationUrlOnMoneyRequestDelete} from '@userActions/IOU'; import { clearAvatarErrors, clearPolicyRoomNameErrors, @@ -152,7 +140,6 @@ type CaseID = ValueOf; function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDetailsPageProps) { const {translate} = useLocalize(); const {isOffline} = useNetwork(); - const {canUseTableReportView} = usePermissions(); const styles = useThemeStyles(); const backTo = route.params.backTo; @@ -167,10 +154,6 @@ function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDeta const {reportActions} = usePaginatedReportActions(report.reportID); - // We need to use isSmallScreenWidth instead of shouldUseNarrowLayout to apply the correct modal type for the decision modal - // eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth - const {isSmallScreenWidth} = useResponsiveLayout(); - const transactionThreadReportID = useMemo(() => getOneTransactionThreadReportID(report.reportID, reportActions ?? [], isOffline), [report.reportID, reportActions, isOffline]); /* eslint-disable @typescript-eslint/prefer-nullish-coalescing */ @@ -183,10 +166,6 @@ function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDeta const [isLastMemberLeavingGroupModalVisible, setIsLastMemberLeavingGroupModalVisible] = useState(false); const [isDeleteModalVisible, setIsDeleteModalVisible] = useState(false); - const [isUnapproveModalVisible, setIsUnapproveModalVisible] = useState(false); - const [isConfirmModalVisible, setIsConfirmModalVisible] = useState(false); - const [offlineModalVisible, setOfflineModalVisible] = useState(false); - const [downloadErrorModalVisible, setDownloadErrorModalVisible] = useState(false); const policy = useMemo(() => policies?.[`${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`], [policies, report?.policyID]); const isPolicyAdmin = useMemo(() => isPolicyAdminUtil(policy), [policy]); const isPolicyEmployee = useMemo(() => isPolicyEmployeeUtil(report?.policyID, policies), [report?.policyID, policies]); @@ -234,7 +213,6 @@ function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDeta const participants = useMemo(() => { return getParticipantsList(report, personalDetails, shouldOpenRoomMembersPage); }, [report, personalDetails, shouldOpenRoomMembersPage]); - const connectedIntegration = getConnectedIntegration(policy); let caseID: CaseID; if (isMoneyRequestReport || isInvoiceReport) { @@ -318,8 +296,6 @@ function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDeta }); }, [isPolicyEmployee, isPolicyExpenseChat, isRootGroupChat, report.reportID, report.visibility]); - const [isNoDelegateAccessMenuVisible, setIsNoDelegateAccessMenuVisible] = useState(false); - const shouldShowLeaveButton = canLeaveChat(report, policy); const shouldShowGoToWorkspace = shouldShowPolicy(policy, false, session?.email) && !policy?.isJoinRequestPending; @@ -342,16 +318,6 @@ function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDeta const shouldShowNotificationPref = !isMoneyRequestReport && !isHiddenForCurrentUser(report); const shouldShowWriteCapability = !isMoneyRequestReport; const shouldShowMenuItem = shouldShowNotificationPref || shouldShowWriteCapability || (!!report?.visibility && report.chatType !== CONST.REPORT.CHAT_TYPE.INVOICE); - const [chatReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${moneyRequestReport?.chatReportID}`, {canBeMissing: true}); - - const cancelPayment = useCallback(() => { - if (!chatReport) { - return; - } - - cancelPaymentAction(moneyRequestReport, chatReport); - setIsConfirmModalVisible(false); - }, [moneyRequestReport, chatReport]); const menuItems: ReportDetailsPageMenuItem[] = useMemo(() => { const items: ReportDetailsPageMenuItem[] = []; @@ -580,14 +546,6 @@ function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDeta /> ) : null; - const connectedIntegrationName = connectedIntegration ? translate('workspace.accounting.connectionName', {connectionName: connectedIntegration}) : ''; - const unapproveWarningText = ( - - {translate('iou.headsUp')}{' '} - {translate('iou.unapproveWithIntegrationWarning', {accountingIntegration: connectedIntegrationName})} - - ); - const renderedAvatar = useMemo(() => { if (isMoneyRequestReport || isInvoiceReport) { return ( @@ -935,19 +893,6 @@ function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDeta confirmText={translate('common.leave')} cancelText={translate('common.cancel')} /> - {!canUseTableReportView && ( - setIsConfirmModalVisible(false)} - prompt={translate('iou.cancelPaymentConfirmation')} - confirmText={translate('iou.cancelPayment')} - cancelText={translate('common.dismiss')} - danger - shouldEnableNewFocusManagement - /> - )} - {!canUseTableReportView && ( - setIsNoDelegateAccessMenuVisible(false)} - /> - )} - { - setIsUnapproveModalVisible(false); - Navigation.goBack(backTo); - unapproveExpenseReport(moneyRequestReport); - }} - cancelText={translate('common.cancel')} - onCancel={() => setIsUnapproveModalVisible(false)} - prompt={unapproveWarningText} - /> - setOfflineModalVisible(false)} - secondOptionText={translate('common.buttonConfirm')} - isVisible={offlineModalVisible} - onClose={() => setOfflineModalVisible(false)} - /> - setDownloadErrorModalVisible(false)} - secondOptionText={translate('common.buttonConfirm')} - isVisible={downloadErrorModalVisible} - onClose={() => setDownloadErrorModalVisible(false)} - /> );