From 728c10e59bd47b3223c38b853f8bf771f4dbf28a Mon Sep 17 00:00:00 2001 From: Rodrigo Lino da Costa <5201282+rlinoz@users.noreply.github.com> Date: Tue, 9 Dec 2025 11:57:20 -0300 Subject: [PATCH 1/3] Revert "Deprecated canDelete field" --- src/components/Search/index.tsx | 12 +-- src/hooks/useSelectedTransactionsActions.ts | 4 +- src/libs/ReportSecondaryActionUtils.ts | 3 +- src/libs/ReportUtils.ts | 93 ++++--------------- src/libs/SearchUIUtils.ts | 1 + src/pages/ReportDetailsPage.tsx | 4 +- src/types/onyx/SearchResults.ts | 3 + tests/unit/MoneyRequestReportUtilsTest.ts | 1 + tests/unit/ReportUtilsTest.ts | 12 +-- tests/unit/Search/SearchUIUtilsTest.ts | 16 +++- .../Search/handleActionButtonPressTest.ts | 1 + tests/unit/TransactionGroupListItemTest.tsx | 1 + 12 files changed, 57 insertions(+), 94 deletions(-) diff --git a/src/components/Search/index.tsx b/src/components/Search/index.tsx index 285a89575e5b..f39a37d5a7a2 100644 --- a/src/components/Search/index.tsx +++ b/src/components/Search/index.tsx @@ -32,7 +32,7 @@ import Log from '@libs/Log'; import isSearchTopmostFullScreenRoute from '@libs/Navigation/helpers/isSearchTopmostFullScreenRoute'; import type {PlatformStackNavigationProp} from '@libs/Navigation/PlatformStackNavigation/types'; import Performance from '@libs/Performance'; -import {canAddOrDeleteTransactions, canEditFieldOfMoneyRequest, canHoldUnholdReportAction, isOneTransactionReport, selectFilteredReportActions} from '@libs/ReportUtils'; +import {canEditFieldOfMoneyRequest, canHoldUnholdReportAction, isOneTransactionReport, selectFilteredReportActions} from '@libs/ReportUtils'; import {buildCannedSearchQuery, buildSearchQueryJSON, buildSearchQueryString} from '@libs/SearchQueryUtils'; import { createAndOpenSearchTransactionThread, @@ -97,7 +97,7 @@ function mapTransactionItemToSelectedEntry(item: TransactionListItemType, outsta item.keyForList, { isSelected: true, - canDelete: canAddOrDeleteTransactions(item.report, item.policy), + canDelete: item.canDelete, canHold: canHoldRequest, isHeld: isOnHold(item), canUnhold: canUnholdRequest, @@ -179,7 +179,7 @@ function prepareTransactionsList(item: TransactionListItemType, selectedTransact ...selectedTransactions, [item.keyForList]: { isSelected: true, - canDelete: canAddOrDeleteTransactions(item.report, item.policy), + canDelete: item.canDelete, canHold: canHoldRequest, isHeld: isOnHold(item), canUnhold: canUnholdRequest, @@ -514,8 +514,7 @@ function Search({ ), // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing isSelected: areAllMatchingItemsSelected || selectedTransactions[transactionItem.transactionID]?.isSelected || isExpenseReportType, - canDelete: canAddOrDeleteTransactions(transactionItem.report, transactionItem.policy), - + canDelete: transactionItem.canDelete, reportID: transactionItem.reportID, policyID: transactionItem.report?.policyID, amount: transactionItem.modifiedAmount ?? transactionItem.amount, @@ -560,8 +559,7 @@ function Search({ ), // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing isSelected: areAllMatchingItemsSelected || selectedTransactions[transactionItem.transactionID].isSelected, - canDelete: canAddOrDeleteTransactions(transactionItem.report, transactionItem.policy), - + canDelete: transactionItem.canDelete, reportID: transactionItem.reportID, policyID: transactionItem.report?.policyID, amount: transactionItem.modifiedAmount ?? transactionItem.amount, diff --git a/src/hooks/useSelectedTransactionsActions.ts b/src/hooks/useSelectedTransactionsActions.ts index b28d406163ba..5a6d2567dd51 100644 --- a/src/hooks/useSelectedTransactionsActions.ts +++ b/src/hooks/useSelectedTransactionsActions.ts @@ -9,8 +9,8 @@ import Navigation from '@libs/Navigation/Navigation'; import {getIOUActionForTransactionID, getReportAction, isDeletedAction} from '@libs/ReportActionsUtils'; import {isMergeAction} from '@libs/ReportSecondaryActionUtils'; import { - canAddOrDeleteTransactions, canDeleteCardTransactionByLiabilityType, + canDeleteTransaction, canEditFieldOfMoneyRequest, canHoldUnholdReportAction, canUserPerformWriteAction as canUserPerformWriteActionReportUtils, @@ -313,7 +313,7 @@ function useSelectedTransactionsActions({ return canRemoveTransaction && isIOUActionOwner && !isActionDeleted; }); - const canRemoveReportTransaction = canAddOrDeleteTransactions(report, policy, isReportArchived); + const canRemoveReportTransaction = canDeleteTransaction(report, isReportArchived); if (canRemoveReportTransaction && canAllSelectedTransactionsBeRemoved) { options.push({ diff --git a/src/libs/ReportSecondaryActionUtils.ts b/src/libs/ReportSecondaryActionUtils.ts index 646d6d5fc78d..60345938b458 100644 --- a/src/libs/ReportSecondaryActionUtils.ts +++ b/src/libs/ReportSecondaryActionUtils.ts @@ -33,7 +33,7 @@ import { hasOnlyNonReimbursableTransactions, hasReportBeenReopened as hasReportBeenReopenedUtils, hasReportBeenRetracted as hasReportBeenRetractedUtils, - isArchivedReport, // eslint-disable-next-line @typescript-eslint/no-deprecated + isArchivedReport, isAwaitingFirstLevelApproval, isClosedReport as isClosedReportUtils, isCurrentUserSubmitter, @@ -125,7 +125,6 @@ function isSplitAction(report: Report, reportTransactions: Transaction[], origin } // Hide split option for the submitter if the report is forwarded - // eslint-disable-next-line @typescript-eslint/no-deprecated return (isSubmitter && isAwaitingFirstLevelApproval(report)) || isAdmin || isManager; } diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index a605f50a9aaf..b5456372c9ab 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -135,7 +135,6 @@ import { getAccountIDsByLogins, getDisplayNameOrDefault, getEffectiveDisplayName, - getLoginByAccountID, getLoginsByAccountIDs, getPersonalDetailByEmail, getPersonalDetailsByIDs, @@ -147,7 +146,6 @@ import { getCleanedTagName, getConnectedIntegration, getCorrectedAutoReportingFrequency, - getDefaultApprover, getForwardsToAccount, getManagerAccountEmail, getManagerAccountID, @@ -157,7 +155,6 @@ import { getRuleApprovers, getSubmitToAccountID, hasDependentTags as hasDependentTagsPolicyUtils, - hasDynamicExternalWorkflow, isExpensifyTeam, isInstantSubmitEnabled, isPaidGroupPolicy as isPaidGroupPolicyPolicyUtils, @@ -1441,7 +1438,7 @@ function isIOUReport(reportOrID: OnyxInputOrEntry | string): boolean { /** * Checks if a report is an IOU report using report */ -function isIOUReportUsingReport(report: OnyxEntry): boolean { +function isIOUReportUsingReport(report: OnyxEntry): report is Report { return report?.type === CONST.REPORT.TYPE.IOU; } @@ -1966,9 +1963,6 @@ function requiresManualSubmission(report: OnyxEntry, policy: OnyxEntry

): boolean { if (!report) { return false; @@ -1981,63 +1975,6 @@ function isAwaitingFirstLevelApproval(report: OnyxEntry): boolean { return isProcessingReport(report) && submitsToAccountID === report.managerID; } -function isAwaitingFirstLevelApprovalNew(report: OnyxEntry, reportActions: ReportAction[], policy: OnyxEntry): boolean { - if (!report) { - return false; - } - - if (!isProcessingReport(report)) { - return false; - } - - if (isIOUReportUsingReport(report)) { - return true; - } - - if (hasDynamicExternalWorkflow(policy)) { - return false; - } - - if (policy?.approvalMode === CONST.POLICY.APPROVAL_MODE.BASIC) { - return true; - } - - // If the report is part of a policy with Instant Submit, this data should be stored in the CREATED action - // as Instant Submit reports do not have a SUBMITTED action. - // For all other cases, use the most recent SUBMITTED action instead. - const usedReportAction = isInstantSubmitEnabled(policy) - ? reportActions?.find((action) => action.actionName === CONST.REPORT.ACTIONS.TYPE.CREATED) - : reportActions - ?.filter((action) => action.actionName === CONST.REPORT.ACTIONS.TYPE.SUBMITTED) - ?.sort((a, b) => { - if (!a.created || !b.created) { - return !a.created ? 1 : -1; - } - return a.created < b.created ? 1 : -1; - }) - ?.at(0); - - const originalMessage = getOriginalMessage(usedReportAction); - if (!originalMessage) { - return false; - } - let submittedTo: number | undefined = 'submittedTo' in originalMessage ? originalMessage?.submittedTo : undefined; - - if (!submittedTo) { - const submittedToLogin = 'to' in originalMessage ? (originalMessage?.to ?? '') : ''; - submittedTo = getAccountIDsByLogins([submittedToLogin])?.at(0); - } - - if (!submittedTo) { - const managerID = 'managerOnVacation' in originalMessage && originalMessage?.managerOnVacation ? originalMessage?.managerOnVacation : report.managerID; - const approverAccountID = - policy?.employeeList?.[getLoginByAccountID(report?.ownerAccountID ?? CONST.DEFAULT_NUMBER_ID) ?? '']?.submitsTo ?? getAccountIDsByLogins([getDefaultApprover(policy)])?.at(0); - return managerID === approverAccountID; - } - - return report.managerID === submittedTo; -} - /** * Updates optimistic transaction violations to OnyxData for the given policy and categories onyx update. * @@ -2747,17 +2684,21 @@ function getChildReportNotificationPreference(reportAction: OnyxInputOrEntry, policy?: OnyxEntry, isReportArchived = false): boolean { +function canAddOrDeleteTransactions(moneyRequestReport: OnyxEntry, isReportArchived = false): boolean { if (!isMoneyRequestReport(moneyRequestReport) || isReportArchived) { return false; } + // This will be fixed as part of https://github.com/Expensify/Expensify/issues/507850 + // eslint-disable-next-line @typescript-eslint/no-deprecated + const policy = getPolicy(moneyRequestReport?.policyID); + // Adding or deleting transactions is not allowed on a closed report if (moneyRequestReport?.statusNum === CONST.REPORT.STATUS_NUM.CLOSED && !isOpenReport(moneyRequestReport)) { return false; } if (isInstantSubmitEnabled(policy) && isProcessingReport(moneyRequestReport)) { - return isAwaitingFirstLevelApprovalNew(moneyRequestReport, Object.values(allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${moneyRequestReport?.reportID}`] ?? {}), policy); + return isAwaitingFirstLevelApproval(moneyRequestReport); } if (isReportApproved({report: moneyRequestReport}) || isClosedReport(moneyRequestReport) || isSettled(moneyRequestReport?.reportID)) { @@ -2786,7 +2727,17 @@ function canAddTransaction(moneyRequestReport: OnyxEntry, isReportArchiv return false; } - return canAddOrDeleteTransactions(moneyRequestReport, policy, isReportArchived); + return canAddOrDeleteTransactions(moneyRequestReport, isReportArchived); +} + +/** + * Checks whether the supplied report supports deleting more transactions from it. + * Return true if: + * - report is a non-settled IOU + * - report is a non-approved IOU + */ +function canDeleteTransaction(moneyRequestReport: OnyxEntry, isReportArchived = false): boolean { + return canAddOrDeleteTransactions(moneyRequestReport, isReportArchived); } /** @@ -2816,7 +2767,6 @@ function isMoneyRequestReportEligibleForMerge(reportID: string, isAdmin: boolean } if (isSubmitter) { - // eslint-disable-next-line @typescript-eslint/no-deprecated return isOpenReport(report) || (isIOUReport(report) && isProcessingReport(report)) || isAwaitingFirstLevelApproval(report); } @@ -3003,7 +2953,7 @@ function canDeleteReportAction( if (isActionOwner) { if (!isEmptyObject(report) && (isMoneyRequestReport(report) || isInvoiceReport(report))) { - return canAddOrDeleteTransactions(report, policy ?? undefined) && canCardTransactionBeDeleted; + return canDeleteTransaction(report) && canCardTransactionBeDeleted; } if (isTrackExpenseAction(reportAction)) { return canCardTransactionBeDeleted; @@ -4709,7 +4659,6 @@ function canEditReportPolicy(report: OnyxEntry, reportPolicy: OnyxEntry< } if (isSubmitted) { - // eslint-disable-next-line @typescript-eslint/no-deprecated return (isSubmitter && isAwaitingFirstLevelApproval(report)) || isManager || isAdmin; } @@ -13032,7 +12981,7 @@ export { canAccessReport, isReportNotFound, canAddTransaction, - canAddOrDeleteTransactions, + canDeleteTransaction, canBeAutoReimbursed, canCreateRequest, canCreateTaskInReport, @@ -13248,9 +13197,7 @@ export { isOpenReport, requiresManualSubmission, isReportIDApproved, - // eslint-disable-next-line @typescript-eslint/no-deprecated isAwaitingFirstLevelApproval, - isAwaitingFirstLevelApprovalNew, isPublicAnnounceRoom, isPublicRoom, isReportApproved, diff --git a/src/libs/SearchUIUtils.ts b/src/libs/SearchUIUtils.ts index b7460981d5e3..8bc327aac487 100644 --- a/src/libs/SearchUIUtils.ts +++ b/src/libs/SearchUIUtils.ts @@ -2659,6 +2659,7 @@ function getTransactionFromTransactionListItem(item: TransactionListItemType): O isTaxAmountColumnWide, violations, hash, + canDelete, accountID, policyID, ...transaction diff --git a/src/pages/ReportDetailsPage.tsx b/src/pages/ReportDetailsPage.tsx index f99ba81a3dd3..a8f1257a37af 100644 --- a/src/pages/ReportDetailsPage.tsx +++ b/src/pages/ReportDetailsPage.tsx @@ -48,8 +48,8 @@ import Permissions from '@libs/Permissions'; import {isPolicyAdmin as isPolicyAdminUtil, isPolicyEmployee as isPolicyEmployeeUtil, shouldShowPolicy} from '@libs/PolicyUtils'; import {getOneTransactionThreadReportID, getOriginalMessage, getTrackExpenseActionableWhisper, isDeletedAction, isMoneyRequestAction, isTrackExpenseAction} from '@libs/ReportActionsUtils'; import { - canAddOrDeleteTransactions, canDeleteCardTransactionByLiabilityType, + canDeleteTransaction, canEditReportDescription as canEditReportDescriptionUtil, canJoinChat, canLeaveChat, @@ -291,7 +291,7 @@ function ReportDetailsPage({policy, report, route, reportMetadata}: ReportDetail !isClosedReport(report) && isTaskModifiable && isTaskActionable; - const canDeleteRequest = isActionOwner && (canAddOrDeleteTransactions(moneyRequestReport, policy, isMoneyRequestReportArchived) || isSelfDMTrackExpenseReport) && !isDeletedParentAction; + const canDeleteRequest = isActionOwner && (canDeleteTransaction(moneyRequestReport, isMoneyRequestReportArchived) || isSelfDMTrackExpenseReport) && !isDeletedParentAction; const iouTransactionID = isMoneyRequestAction(requestParentReportAction) ? getOriginalMessage(requestParentReportAction)?.IOUTransactionID : undefined; const [iouTransaction] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION}${iouTransactionID}`, {canBeMissing: true}); const {duplicateTransactions, duplicateTransactionViolations} = useDuplicateTransactionsAndViolations(iouTransactionID ? [iouTransactionID] : []); diff --git a/src/types/onyx/SearchResults.ts b/src/types/onyx/SearchResults.ts index 8b90d653cbbb..08b66a5086af 100644 --- a/src/types/onyx/SearchResults.ts +++ b/src/types/onyx/SearchResults.ts @@ -86,6 +86,9 @@ type SearchTransaction = { /** The transaction amount */ amount: number; + /** If the transaction can be deleted */ + canDelete: boolean; + /** The edited transaction amount */ modifiedAmount: number; diff --git a/tests/unit/MoneyRequestReportUtilsTest.ts b/tests/unit/MoneyRequestReportUtilsTest.ts index 9cae1e021d32..7bfdb2105183 100644 --- a/tests/unit/MoneyRequestReportUtilsTest.ts +++ b/tests/unit/MoneyRequestReportUtilsTest.ts @@ -55,6 +55,7 @@ const transactionItemBaseMock: TransactionListItemType = { policy: policyBaseMock, reportAction: reportActionBaseMock, holdReportAction: undefined, + canDelete: true, cardID: undefined, cardName: undefined, category: '', diff --git a/tests/unit/ReportUtilsTest.ts b/tests/unit/ReportUtilsTest.ts index e19d7b60c42f..73edb37cfb97 100644 --- a/tests/unit/ReportUtilsTest.ts +++ b/tests/unit/ReportUtilsTest.ts @@ -30,11 +30,11 @@ import { buildOptimisticReportPreview, buildParticipantsFromAccountIDs, buildTransactionThread, - canAddOrDeleteTransactions, canAddTransaction, canCreateRequest, canDeleteMoneyRequestReport, canDeleteReportAction, + canDeleteTransaction, canEditMoneyRequest, canEditReportDescription, canEditRoomVisibility, @@ -5985,7 +5985,7 @@ describe('ReportUtils', () => { }); }); - describe('canAddOrDeleteTransactions', () => { + describe('canDeleteTransaction', () => { it('should return true for a non-archived report', async () => { // Given a non-archived expense report const report: Report = { @@ -5997,7 +5997,7 @@ describe('ReportUtils', () => { // When it's checked if the transactions can be deleted // Simulate how components determined if a report is archived by using this hook const {result: isReportArchived} = renderHook(() => useReportIsArchived(report?.reportID)); - const result = canAddOrDeleteTransactions(report, policy, isReportArchived.current); + const result = canDeleteTransaction(report, isReportArchived.current); // Then the result is true expect(result).toBe(true); @@ -6014,7 +6014,7 @@ describe('ReportUtils', () => { // When it's checked if the transactions can be deleted const {result: isReportArchived} = renderHook(() => useReportIsArchived(report?.reportID)); - const result = canAddOrDeleteTransactions(report, policy, isReportArchived.current); + const result = canDeleteTransaction(report, isReportArchived.current); // Then the result is false expect(result).toBe(false); @@ -6063,7 +6063,7 @@ describe('ReportUtils', () => { await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${openReport.reportID}`, openReport); - expect(canAddOrDeleteTransactions(openReport, policy, false)).toBe(true); + expect(canDeleteTransaction(openReport, false)).toBe(true); }); it('should return false for closed report when workflow is disabled', async () => { @@ -6076,7 +6076,7 @@ describe('ReportUtils', () => { await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${closedReport.reportID}`, closedReport); - expect(canAddOrDeleteTransactions(closedReport, policy, false)).toBe(false); + expect(canDeleteTransaction(closedReport, false)).toBe(false); }); }); }); diff --git a/tests/unit/Search/SearchUIUtilsTest.ts b/tests/unit/Search/SearchUIUtilsTest.ts index 6abd283de26b..2d689a07118d 100644 --- a/tests/unit/Search/SearchUIUtilsTest.ts +++ b/tests/unit/Search/SearchUIUtilsTest.ts @@ -386,6 +386,7 @@ const searchResults: OnyxTypes.SearchResults = { [`report_${reportID5}`]: report5, [`transactions_${transactionID}`]: { amount: -5000, + canDelete: true, cardID: undefined, cardName: undefined, category: '', @@ -415,6 +416,7 @@ const searchResults: OnyxTypes.SearchResults = { }, [`transactions_${transactionID2}`]: { amount: -5000, + canDelete: true, cardID: undefined, cardName: undefined, category: '', @@ -445,6 +447,7 @@ const searchResults: OnyxTypes.SearchResults = { ...allViolations, [`transactions_${transactionID3}`]: { amount: 1200, + canDelete: true, cardID: undefined, cardName: undefined, category: '', @@ -474,6 +477,7 @@ const searchResults: OnyxTypes.SearchResults = { }, [`transactions_${transactionID4}`]: { amount: 3200, + canDelete: true, cardID: undefined, cardName: undefined, category: '', @@ -759,6 +763,7 @@ const transactionsListItems = [ policy, reportAction: reportAction1, holdReportAction: undefined, + canDelete: true, cardID: undefined, cardName: undefined, category: '', @@ -810,6 +815,7 @@ const transactionsListItems = [ policy, reportAction: reportAction2, holdReportAction: undefined, + canDelete: true, cardID: undefined, cardName: undefined, category: '', @@ -871,6 +877,7 @@ const transactionsListItems = [ policy, reportAction: reportAction3, holdReportAction: undefined, + canDelete: true, cardID: undefined, cardName: undefined, category: '', @@ -927,6 +934,7 @@ const transactionsListItems = [ policy, reportAction: reportAction4, holdReportAction: undefined, + canDelete: true, cardID: undefined, cardName: undefined, category: '', @@ -1020,6 +1028,7 @@ const transactionReportGroupListItems = [ reportAction: reportAction1, holdReportAction: undefined, amount: -5000, + canDelete: true, cardID: undefined, cardName: undefined, category: '', @@ -1114,6 +1123,7 @@ const transactionReportGroupListItems = [ reportAction: reportAction2, holdReportAction: undefined, amount: -5000, + canDelete: true, cardID: undefined, cardName: undefined, category: '', @@ -1696,7 +1706,7 @@ describe('SearchUIUtils', () => { expect(distanceTransaction).toBeDefined(); expect(distanceTransaction?.iouRequestType).toBe(CONST.IOU.REQUEST_TYPE.DISTANCE); - const expectedPropertyCount = 45; + const expectedPropertyCount = 46; expect(Object.keys(distanceTransaction ?? {}).length).toBe(expectedPropertyCount); }); @@ -1729,7 +1739,7 @@ describe('SearchUIUtils', () => { expect(distanceTransaction).toBeDefined(); expect(distanceTransaction?.iouRequestType).toBe(CONST.IOU.REQUEST_TYPE.DISTANCE); - const expectedPropertyCount = 45; + const expectedPropertyCount = 46; expect(Object.keys(distanceTransaction ?? {}).length).toBe(expectedPropertyCount); }); @@ -2321,6 +2331,7 @@ describe('SearchUIUtils', () => { // eslint-disable-next-line @typescript-eslint/naming-convention transactions_1805965960759424086: { amount: 0, + canDelete: false, category: 'Employee Meals Remote (Fringe Benefit)', comment: { comment: '', @@ -2443,6 +2454,7 @@ describe('SearchUIUtils', () => { // eslint-disable-next-line @typescript-eslint/naming-convention transactions_1805965960759424086: { amount: 0, + canDelete: false, cardID: undefined, cardName: undefined, category: 'Employee Meals Remote (Fringe Benefit)', diff --git a/tests/unit/Search/handleActionButtonPressTest.ts b/tests/unit/Search/handleActionButtonPressTest.ts index 5eda3218fc48..4deb193a807c 100644 --- a/tests/unit/Search/handleActionButtonPressTest.ts +++ b/tests/unit/Search/handleActionButtonPressTest.ts @@ -181,6 +181,7 @@ const mockReportItemWithHold = { action: 'view', allActions: ['view'], amount: -12300, + canDelete: true, category: '', comment: { comment: '', diff --git a/tests/unit/TransactionGroupListItemTest.tsx b/tests/unit/TransactionGroupListItemTest.tsx index 05cc0ab57376..6e360fdafeb7 100644 --- a/tests/unit/TransactionGroupListItemTest.tsx +++ b/tests/unit/TransactionGroupListItemTest.tsx @@ -26,6 +26,7 @@ jest.mock('@libs/SearchUIUtils', () => ({ const mockTransaction: TransactionListItemType = { accountID: 1, amount: 0, + canDelete: true, category: '', groupAmount: 1284, groupCurrency: 'USD', From d47c9782776cd0ed62c82e12e57ee9891867df95 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Tue, 9 Dec 2025 15:06:17 -0700 Subject: [PATCH 2/3] fix failing test --- tests/unit/hooks/useSelectedTransactionsActions.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/unit/hooks/useSelectedTransactionsActions.test.ts b/tests/unit/hooks/useSelectedTransactionsActions.test.ts index 6450e46df997..16011a799d92 100644 --- a/tests/unit/hooks/useSelectedTransactionsActions.test.ts +++ b/tests/unit/hooks/useSelectedTransactionsActions.test.ts @@ -292,7 +292,6 @@ describe('useSelectedTransactionsActions', () => { await Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, transaction); jest.spyOn(require('@libs/ReportUtils'), 'canDeleteCardTransactionByLiabilityType').mockReturnValue(true); - jest.spyOn(require('@libs/ReportUtils'), 'canAddOrDeleteTransactions').mockReturnValue(true); jest.spyOn(require('@libs/ReportActionsUtils'), 'isDeletedAction').mockReturnValue(false); jest.spyOn(require('@libs/ReportActionsUtils'), 'getIOUActionForTransactionID').mockReturnValue(reportActions.at(0) as OnyxEntry); From eee4b2b9da51431546a59f13328f13525ecb7114 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Tue, 9 Dec 2025 15:54:32 -0700 Subject: [PATCH 3/3] fix test --- tests/unit/ReportUtilsTest.ts | 1 - tests/unit/hooks/useSelectedTransactionsActions.test.ts | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/ReportUtilsTest.ts b/tests/unit/ReportUtilsTest.ts index 453e439d0d4f..8d42accd771a 100644 --- a/tests/unit/ReportUtilsTest.ts +++ b/tests/unit/ReportUtilsTest.ts @@ -2950,7 +2950,6 @@ describe('ReportUtils', () => { submitsTo: currentUserEmail, }, }, - approvalMode: CONST.POLICY.APPROVAL_MODE.BASIC, }; Promise.all([ Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${paidPolicy.id}`, paidPolicy), diff --git a/tests/unit/hooks/useSelectedTransactionsActions.test.ts b/tests/unit/hooks/useSelectedTransactionsActions.test.ts index 16011a799d92..31738985991b 100644 --- a/tests/unit/hooks/useSelectedTransactionsActions.test.ts +++ b/tests/unit/hooks/useSelectedTransactionsActions.test.ts @@ -292,6 +292,7 @@ describe('useSelectedTransactionsActions', () => { await Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, transaction); jest.spyOn(require('@libs/ReportUtils'), 'canDeleteCardTransactionByLiabilityType').mockReturnValue(true); + jest.spyOn(require('@libs/ReportUtils'), 'canDeleteTransaction').mockReturnValue(true); jest.spyOn(require('@libs/ReportActionsUtils'), 'isDeletedAction').mockReturnValue(false); jest.spyOn(require('@libs/ReportActionsUtils'), 'getIOUActionForTransactionID').mockReturnValue(reportActions.at(0) as OnyxEntry);