From acc61631cf9786e48c09a25d5300c5a08892e19c Mon Sep 17 00:00:00 2001 From: dmkt9 Date: Tue, 18 Nov 2025 22:09:24 +0700 Subject: [PATCH 1/6] Fix - Flip option is shown in confirmation page in amount section --- src/libs/ReportUtils.ts | 6 ++++-- src/pages/iou/request/step/IOURequestStepAmount.tsx | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 3144a77f86ff..6aeee976fe08 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -1911,9 +1911,11 @@ function isSelfDMOrSelfDMThread(report: OnyxEntry): boolean { /** * Returns true if the report is an expense report, a group policy, a self-DM, or the iouType is create, and the iouType is not split or invoice. */ -function shouldEnableNegative(report: OnyxEntry, policy?: OnyxEntry, iouType?: string) { +function shouldEnableNegative(report: OnyxEntry, policy?: OnyxEntry, iouType?: string, participants?: Participant[]) { const isSelfDMReport = isSelfDMOrSelfDMThread(report); - const isFirstTimeCreatingReport = !report && !policy && iouType === CONST.IOU.TYPE.SUBMIT; + + const isUserInRecipients = participants?.some((participant) => !participant.isSender && !participant.isPolicyExpenseChat && participant.accountID); + const isFirstTimeCreatingReport = !report && !policy && iouType === CONST.IOU.TYPE.SUBMIT && !isUserInRecipients; const isExpenseReportType = isExpenseReport(report); const isGroupPolicyType = isGroupPolicy(policy?.type ?? ''); diff --git a/src/pages/iou/request/step/IOURequestStepAmount.tsx b/src/pages/iou/request/step/IOURequestStepAmount.tsx index e96640d0fa61..d6ff8ae34078 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.tsx +++ b/src/pages/iou/request/step/IOURequestStepAmount.tsx @@ -99,7 +99,7 @@ function IOURequestStepAmount({ const isSubmitType = iouType === CONST.IOU.TYPE.SUBMIT; const isEditingSplitBill = isEditing && isSplitBill; const currentTransaction = isEditingSplitBill && !isEmptyObject(splitDraftTransaction) ? splitDraftTransaction : transaction; - const allowNegative = shouldEnableNegative(report, policy, iouType); + const allowNegative = shouldEnableNegative(report, policy, iouType, transaction?.participants); const disableOppositeConversion = isCreateAction || (isSubmitType && isSubmitAction); const {amount: transactionAmount} = getTransactionDetails(currentTransaction, undefined, undefined, allowNegative, disableOppositeConversion) ?? {amount: 0}; const {currency: originalCurrency} = getTransactionDetails(isEditing && !isEmptyObject(draftTransaction) ? draftTransaction : transaction) ?? {currency: CONST.CURRENCY.USD}; From b41e28b7155190ec8c4509c5d5b286fbd31961db Mon Sep 17 00:00:00 2001 From: dmkt9 Date: Thu, 20 Nov 2025 16:03:36 +0700 Subject: [PATCH 2/6] Fix - Flip option is shown in confirmation page in amount section --- tests/unit/ReportUtilsTest.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/unit/ReportUtilsTest.ts b/tests/unit/ReportUtilsTest.ts index 3d4a79d9e5ea..cb747ec64548 100644 --- a/tests/unit/ReportUtilsTest.ts +++ b/tests/unit/ReportUtilsTest.ts @@ -8177,6 +8177,20 @@ describe('ReportUtils', () => { expect(shouldEnableNegative(undefined, undefined, CONST.IOU.TYPE.CREATE)).toBe(true); }); + it('should return true when report is null and iouType is SUBMIT', () => { + expect(shouldEnableNegative(undefined, undefined, CONST.IOU.TYPE.SUBMIT)).toBe(true); + }); + + it("should return true when report is null, the iouType is SUBMIT, and the receipts do not include a user", () => { + const participants = [{accountID: 0, isPolicyExpenseChat: true, isSender: false}]; + expect(shouldEnableNegative(undefined, undefined, CONST.IOU.TYPE.SUBMIT, participants)).toBe(true); + }); + + it("should return false when report is null, the iouType is SUBMIT, and the receipts include a user", () => { + const participants = [{accountID: 1, isPolicyExpenseChat: false, isSender: false}]; + expect(shouldEnableNegative(undefined, undefined, CONST.IOU.TYPE.SUBMIT, participants)).toBe(false); + }); + it('should handle undefined policy type gracefully', () => { const policyWithUndefinedType = { ...createRandomPolicy(4), From 7b3f79a2995a3a55fbf15c933a5c3352323900dd Mon Sep 17 00:00:00 2001 From: dmkt9 Date: Thu, 20 Nov 2025 16:47:06 +0700 Subject: [PATCH 3/6] fix lint --- src/libs/ReportUtils.ts | 33 ++++++++++++++++----------------- tests/unit/ReportUtilsTest.ts | 23 +++++++++++------------ 2 files changed, 27 insertions(+), 29 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 39f3817d58ce..ffb1c4220b11 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -75,7 +75,6 @@ import type {NotificationPreference, Participants, Participant as ReportParticip import type {Message, OldDotReportAction, ReportActions} from '@src/types/onyx/ReportAction'; import type {PendingChatMember} from '@src/types/onyx/ReportMetadata'; import type {OnyxData} from '@src/types/onyx/Request'; -import type {SearchTransaction} from '@src/types/onyx/SearchResults'; import type {Comment, TransactionChanges, WaypointCollection} from '@src/types/onyx/Transaction'; import type {FileObject} from '@src/types/utils/Attachment'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; @@ -924,7 +923,7 @@ type GetReportNameParams = { parentReportActionParam?: OnyxInputOrEntry; personalDetails?: Partial; invoiceReceiverPolicy?: OnyxEntry; - transactions?: SearchTransaction[]; + transactions?: Transaction[]; reports?: Report[]; policies?: Policy[]; isReportArchived?: boolean; @@ -2248,7 +2247,7 @@ function findLastAccessedReport(ignoreDomainRooms: boolean, openOnAdminRoom = fa /** * Whether the provided report has expenses */ -function hasExpenses(reportID?: string, transactions?: SearchTransaction[] | Array>): boolean { +function hasExpenses(reportID?: string, transactions?: Transaction[] | Array>): boolean { if (transactions) { return !!transactions?.find((transaction) => transaction?.reportID === reportID); } @@ -2258,7 +2257,7 @@ function hasExpenses(reportID?: string, transactions?: SearchTransaction[] | Arr /** * Whether the provided report is a closed expense report with no expenses */ -function isClosedExpenseReportWithNoExpenses(report: OnyxEntry, transactions?: SearchTransaction[] | Array>): boolean { +function isClosedExpenseReportWithNoExpenses(report: OnyxEntry, transactions?: Transaction[] | Array>): boolean { if (!report?.statusNum || report.statusNum !== CONST.REPORT.STATUS_NUM.CLOSED || !isExpenseReport(report)) { return false; } @@ -4484,7 +4483,7 @@ function canEditMoneyRequest( isChatReportArchived = false, report?: OnyxInputOrEntry, policy?: OnyxEntry, - linkedTransaction?: OnyxEntry | SearchTransaction, + linkedTransaction?: OnyxEntry | Transaction, ): boolean { const isDeleted = isDeletedAction(reportAction); @@ -4626,7 +4625,7 @@ function canEditFieldOfMoneyRequest( isDeleteAction?: boolean, isChatReportArchived = false, outstandingReportsByPolicyID?: OutstandingReportsByPolicyIDDerivedValue, - linkedTransaction?: OnyxEntry | SearchTransaction, + linkedTransaction?: OnyxEntry | Transaction, report?: OnyxInputOrEntry, policy?: OnyxEntry, ): boolean { @@ -4908,7 +4907,7 @@ function areAllRequestsBeingSmartScanned(iouReportID: string | undefined, report * * NOTE: This method is only meant to be used inside this action file. Do not export and use it elsewhere. Use useOnyx instead. */ -function getLinkedTransaction(reportAction: OnyxEntry, transactions?: SearchTransaction[]): OnyxEntry | SearchTransaction { +function getLinkedTransaction(reportAction: OnyxEntry, transactions?: Transaction[]): OnyxEntry | Transaction { let transactionID: string | undefined; if (isMoneyRequestAction(reportAction)) { @@ -4963,7 +4962,7 @@ function getTransactionReportName({ reports, }: { reportAction: OnyxEntry; - transactions?: SearchTransaction[]; + transactions?: Transaction[]; reports?: Report[]; }): string { if (isReversedTransaction(reportAction)) { @@ -5596,7 +5595,7 @@ function getReportName( personalDetails?: Partial, invoiceReceiverPolicy?: OnyxEntry, reportAttributes?: ReportAttributesDerivedValue['reports'], - transactions?: SearchTransaction[], + transactions?: Transaction[], isReportArchived?: boolean, reports?: Report[], policies?: Policy[], @@ -8897,7 +8896,7 @@ function hasViolations( reportID: string | undefined, transactionViolations: OnyxCollection, shouldShowInReview?: boolean, - reportTransactions?: SearchTransaction[], + reportTransactions?: Transaction[], ): boolean { const transactions = reportTransactions ?? getReportTransactions(reportID); return transactions.some((transaction) => hasViolation(transaction, transactionViolations, shouldShowInReview)); @@ -8910,7 +8909,7 @@ function hasWarningTypeViolations( reportID: string | undefined, transactionViolations: OnyxCollection, shouldShowInReview?: boolean, - reportTransactions?: SearchTransaction[], + reportTransactions?: Transaction[], ): boolean { const transactions = reportTransactions ?? getReportTransactions(reportID); return transactions.some((transaction) => hasWarningTypeViolation(transaction, transactionViolations, shouldShowInReview)); @@ -8943,7 +8942,7 @@ function hasNoticeTypeViolations( reportID: string | undefined, transactionViolations: OnyxCollection, shouldShowInReview?: boolean, - reportTransactions?: SearchTransaction[], + reportTransactions?: Transaction[], ): boolean { const transactions = reportTransactions ?? getReportTransactions(reportID); return transactions.some((transaction) => hasNoticeTypeViolation(transaction, transactionViolations, shouldShowInReview)); @@ -8952,7 +8951,7 @@ function hasNoticeTypeViolations( /** * Checks to see if a report contains any type of violation */ -function hasAnyViolations(reportID: string | undefined, transactionViolations: OnyxCollection, reportTransactions?: SearchTransaction[]) { +function hasAnyViolations(reportID: string | undefined, transactionViolations: OnyxCollection, reportTransactions?: Transaction[]) { return ( hasViolations(reportID, transactionViolations, undefined, reportTransactions) || hasNoticeTypeViolations(reportID, transactionViolations, true, reportTransactions) || @@ -8976,12 +8975,12 @@ function shouldBlockSubmitDueToStrictPolicyRules( reportID: string | undefined, transactionViolations: OnyxCollection, areStrictPolicyRulesEnabled: boolean, - reportTransactions?: Transaction[] | SearchTransaction[], + reportTransactions?: Transaction[] | Transaction[], ) { if (!areStrictPolicyRulesEnabled) { return false; } - return hasAnyViolations(reportID, transactionViolations, reportTransactions as SearchTransaction[]); + return hasAnyViolations(reportID, transactionViolations, reportTransactions as Transaction[]); } type ReportErrorsAndReportActionThatRequiresAttention = { @@ -10334,7 +10333,7 @@ function getAllHeldTransactions(iouReportID?: string): Transaction[] { /** * Check if Report has any held expenses */ -function hasHeldExpenses(iouReportID?: string, allReportTransactions?: SearchTransaction[]): boolean { +function hasHeldExpenses(iouReportID?: string, allReportTransactions?: Transaction[]): boolean { const iouReportTransactions = getReportTransactions(iouReportID); const transactions = allReportTransactions ?? iouReportTransactions; return transactions.some((transaction) => isOnHoldTransactionUtils(transaction)); @@ -10343,7 +10342,7 @@ function hasHeldExpenses(iouReportID?: string, allReportTransactions?: SearchTra /** * Check if all expenses in the Report are on hold */ -function hasOnlyHeldExpenses(iouReportID?: string, allReportTransactions?: SearchTransaction[]): boolean { +function hasOnlyHeldExpenses(iouReportID?: string, allReportTransactions?: Transaction[]): boolean { const transactionsByIouReportID = getReportTransactions(iouReportID); const reportTransactions = allReportTransactions ?? transactionsByIouReportID; return reportTransactions.length > 0 && !reportTransactions.some((transaction) => !isOnHoldTransactionUtils(transaction)); diff --git a/tests/unit/ReportUtilsTest.ts b/tests/unit/ReportUtilsTest.ts index cb747ec64548..b5efc03e1ad7 100644 --- a/tests/unit/ReportUtilsTest.ts +++ b/tests/unit/ReportUtilsTest.ts @@ -131,7 +131,6 @@ import type {ErrorFields, Errors, OnyxValueWithOfflineFeedback} from '@src/types import type {JoinWorkspaceResolution} from '@src/types/onyx/OriginalMessage'; import type {ACHAccount} from '@src/types/onyx/Policy'; import type {Participant, Participants} from '@src/types/onyx/Report'; -import type {SearchReport, SearchTransaction} from '@src/types/onyx/SearchResults'; import {toCollectionDataSet} from '@src/types/utils/CollectionDataSet'; import {actionR14932 as mockIOUAction} from '../../__mocks__/reportData/actions'; import {chatReportR14932 as mockedChatReport, iouReportR14932 as mockIOUReport} from '../../__mocks__/reportData/reports'; @@ -1663,7 +1662,7 @@ describe('ReportUtils', () => { }, }; - const transaction: SearchTransaction = { + const transaction: Transaction = { transactionID: 'txn1', reportID: '2', amount: 1000, @@ -1671,7 +1670,7 @@ describe('ReportUtils', () => { merchant: 'Test Merchant', created: testDate, modifiedMerchant: 'Test Merchant', - } as SearchTransaction; + } as Transaction; const reportName = getSearchReportName({ report: baseExpenseReport, @@ -8181,12 +8180,12 @@ describe('ReportUtils', () => { expect(shouldEnableNegative(undefined, undefined, CONST.IOU.TYPE.SUBMIT)).toBe(true); }); - it("should return true when report is null, the iouType is SUBMIT, and the receipts do not include a user", () => { + it('should return true when report is null, the iouType is SUBMIT, and the receipts do not include a user', () => { const participants = [{accountID: 0, isPolicyExpenseChat: true, isSender: false}]; expect(shouldEnableNegative(undefined, undefined, CONST.IOU.TYPE.SUBMIT, participants)).toBe(true); }); - it("should return false when report is null, the iouType is SUBMIT, and the receipts include a user", () => { + it('should return false when report is null, the iouType is SUBMIT, and the receipts include a user', () => { const participants = [{accountID: 1, isPolicyExpenseChat: false, isSender: false}]; expect(shouldEnableNegative(undefined, undefined, CONST.IOU.TYPE.SUBMIT, participants)).toBe(false); }); @@ -8630,7 +8629,7 @@ describe('ReportUtils', () => { const mockReportIDIndex = 1; const mockReportID = mockReportIDIndex.toString(); // eslint-disable-next-line @typescript-eslint/no-deprecated - const mockSearchReport: SearchReport = { + const mockSearchReport: Report = { ...createRandomReport(mockReportIDIndex, undefined), reportName: 'Search Report', type: CONST.REPORT.TYPE.CHAT, @@ -8660,7 +8659,7 @@ describe('ReportUtils', () => { test('returns onyx report when search report is not found but onyx report exists', async () => { // eslint-disable-next-line @typescript-eslint/no-deprecated - const searchReports: SearchReport[] = []; + const searchReports: Report[] = []; await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${mockReportID}`, mockOnyxReport); const result = getReportOrDraftReport(mockReportID, searchReports); expect(result).toEqual(mockOnyxReport); @@ -8668,7 +8667,7 @@ describe('ReportUtils', () => { test('returns draft report when neither search nor onyx report exists but draft exists', async () => { // eslint-disable-next-line @typescript-eslint/no-deprecated - const searchReports: SearchReport[] = []; + const searchReports: Report[] = []; await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT_DRAFT}${mockReportID}`, mockDraftReport); const result = getReportOrDraftReport(mockReportID, searchReports); expect(result).toEqual(mockDraftReport); @@ -8676,14 +8675,14 @@ describe('ReportUtils', () => { test('returns fallback report when no other reports exist', () => { // eslint-disable-next-line @typescript-eslint/no-deprecated - const searchReports: SearchReport[] = []; + const searchReports: Report[] = []; const result = getReportOrDraftReport('unknownReportID', searchReports, mockFallbackReport); expect(result).toEqual(mockFallbackReport); }); test('returns undefined when no reports exist and no fallback provided', () => { // eslint-disable-next-line @typescript-eslint/no-deprecated - const searchReports: SearchReport[] = []; + const searchReports: Report[] = []; const result = getReportOrDraftReport(mockReportID, searchReports); expect(result).toBeUndefined(); }); @@ -8715,7 +8714,7 @@ describe('ReportUtils', () => { test('prioritizes onyx report over draft report when both exist', async () => { // eslint-disable-next-line @typescript-eslint/no-deprecated - const searchReports: SearchReport[] = []; + const searchReports: Report[] = []; await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${mockReportID}`, mockOnyxReport); await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT_DRAFT}${mockReportID}`, mockDraftReport); const result = getReportOrDraftReport(mockReportID, searchReports); @@ -8725,7 +8724,7 @@ describe('ReportUtils', () => { test('prioritizes draft report over fallback when both exist', async () => { // eslint-disable-next-line @typescript-eslint/no-deprecated - const searchReports: SearchReport[] = []; + const searchReports: Report[] = []; await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT_DRAFT}${mockReportID}`, mockDraftReport); const result = getReportOrDraftReport(mockReportID, searchReports, mockFallbackReport); expect(result).toEqual(mockDraftReport); From 89d78e71ff6ac604eb1394b1ba786c99bd6ceb95 Mon Sep 17 00:00:00 2001 From: dmkt9 Date: Thu, 20 Nov 2025 16:57:28 +0700 Subject: [PATCH 4/6] fix lint --- src/libs/ReportUtils.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index ffb1c4220b11..e0a6351ad2b8 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -2247,7 +2247,7 @@ function findLastAccessedReport(ignoreDomainRooms: boolean, openOnAdminRoom = fa /** * Whether the provided report has expenses */ -function hasExpenses(reportID?: string, transactions?: Transaction[] | Array>): boolean { +function hasExpenses(reportID?: string, transactions?: Array>): boolean { if (transactions) { return !!transactions?.find((transaction) => transaction?.reportID === reportID); } @@ -2257,7 +2257,7 @@ function hasExpenses(reportID?: string, transactions?: Transaction[] | Array, transactions?: Transaction[] | Array>): boolean { +function isClosedExpenseReportWithNoExpenses(report: OnyxEntry, transactions?: Array>): boolean { if (!report?.statusNum || report.statusNum !== CONST.REPORT.STATUS_NUM.CLOSED || !isExpenseReport(report)) { return false; } @@ -4483,7 +4483,7 @@ function canEditMoneyRequest( isChatReportArchived = false, report?: OnyxInputOrEntry, policy?: OnyxEntry, - linkedTransaction?: OnyxEntry | Transaction, + linkedTransaction?: OnyxEntry, ): boolean { const isDeleted = isDeletedAction(reportAction); @@ -4625,7 +4625,7 @@ function canEditFieldOfMoneyRequest( isDeleteAction?: boolean, isChatReportArchived = false, outstandingReportsByPolicyID?: OutstandingReportsByPolicyIDDerivedValue, - linkedTransaction?: OnyxEntry | Transaction, + linkedTransaction?: OnyxEntry, report?: OnyxInputOrEntry, policy?: OnyxEntry, ): boolean { @@ -4907,7 +4907,7 @@ function areAllRequestsBeingSmartScanned(iouReportID: string | undefined, report * * NOTE: This method is only meant to be used inside this action file. Do not export and use it elsewhere. Use useOnyx instead. */ -function getLinkedTransaction(reportAction: OnyxEntry, transactions?: Transaction[]): OnyxEntry | Transaction { +function getLinkedTransaction(reportAction: OnyxEntry, transactions?: Transaction[]): OnyxEntry { let transactionID: string | undefined; if (isMoneyRequestAction(reportAction)) { @@ -8975,12 +8975,12 @@ function shouldBlockSubmitDueToStrictPolicyRules( reportID: string | undefined, transactionViolations: OnyxCollection, areStrictPolicyRulesEnabled: boolean, - reportTransactions?: Transaction[] | Transaction[], + reportTransactions?: Transaction[], ) { if (!areStrictPolicyRulesEnabled) { return false; } - return hasAnyViolations(reportID, transactionViolations, reportTransactions as Transaction[]); + return hasAnyViolations(reportID, transactionViolations, reportTransactions); } type ReportErrorsAndReportActionThatRequiresAttention = { From 46153baf510838d4eb89e9a083e2a22a787d89af Mon Sep 17 00:00:00 2001 From: dmkt9 Date: Fri, 21 Nov 2025 14:03:32 +0700 Subject: [PATCH 5/6] Merge branch 'main' into fix/75304 --- src/libs/ReportUtils.ts | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 12115182c0d6..e29982dc7171 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -925,7 +925,6 @@ type GetReportNameParams = { personalDetails?: Partial; invoiceReceiverPolicy?: OnyxEntry; transactions?: Transaction[]; - transactions?: Transaction[]; reports?: Report[]; policies?: Policy[]; isReportArchived?: boolean; @@ -5598,7 +5597,6 @@ function getReportName( invoiceReceiverPolicy?: OnyxEntry, reportAttributes?: ReportAttributesDerivedValue['reports'], transactions?: Transaction[], - transactions?: Transaction[], isReportArchived?: boolean, reports?: Report[], policies?: Policy[], @@ -8908,7 +8906,6 @@ function hasViolations( transactionViolations: OnyxCollection, shouldShowInReview?: boolean, reportTransactions?: Transaction[], - reportTransactions?: Transaction[], ): boolean { const transactions = reportTransactions ?? getReportTransactions(reportID); return transactions.some((transaction) => hasViolation(transaction, transactionViolations, shouldShowInReview)); @@ -8922,7 +8919,6 @@ function hasWarningTypeViolations( transactionViolations: OnyxCollection, shouldShowInReview?: boolean, reportTransactions?: Transaction[], - reportTransactions?: Transaction[], ): boolean { const transactions = reportTransactions ?? getReportTransactions(reportID); return transactions.some((transaction) => hasWarningTypeViolation(transaction, transactionViolations, shouldShowInReview)); @@ -8956,7 +8952,6 @@ function hasNoticeTypeViolations( transactionViolations: OnyxCollection, shouldShowInReview?: boolean, reportTransactions?: Transaction[], - reportTransactions?: Transaction[], ): boolean { const transactions = reportTransactions ?? getReportTransactions(reportID); return transactions.some((transaction) => hasNoticeTypeViolation(transaction, transactionViolations, shouldShowInReview)); @@ -8965,7 +8960,6 @@ function hasNoticeTypeViolations( /** * Checks to see if a report contains any type of violation */ -function hasAnyViolations(reportID: string | undefined, transactionViolations: OnyxCollection, reportTransactions?: Transaction[]) { function hasAnyViolations(reportID: string | undefined, transactionViolations: OnyxCollection, reportTransactions?: Transaction[]) { return ( hasViolations(reportID, transactionViolations, undefined, reportTransactions) || @@ -8991,13 +8985,11 @@ function shouldBlockSubmitDueToStrictPolicyRules( transactionViolations: OnyxCollection, areStrictPolicyRulesEnabled: boolean, reportTransactions?: Transaction[], - reportTransactions?: Transaction[], ) { if (!areStrictPolicyRulesEnabled) { return false; } return hasAnyViolations(reportID, transactionViolations, reportTransactions); - return hasAnyViolations(reportID, transactionViolations, reportTransactions); } type ReportErrorsAndReportActionThatRequiresAttention = { @@ -10350,7 +10342,6 @@ function getAllHeldTransactions(iouReportID?: string): Transaction[] { /** * Check if Report has any held expenses */ -function hasHeldExpenses(iouReportID?: string, allReportTransactions?: Transaction[]): boolean { function hasHeldExpenses(iouReportID?: string, allReportTransactions?: Transaction[]): boolean { const iouReportTransactions = getReportTransactions(iouReportID); const transactions = allReportTransactions ?? iouReportTransactions; @@ -10360,7 +10351,6 @@ function hasHeldExpenses(iouReportID?: string, allReportTransactions?: Transacti /** * Check if all expenses in the Report are on hold */ -function hasOnlyHeldExpenses(iouReportID?: string, allReportTransactions?: Transaction[]): boolean { function hasOnlyHeldExpenses(iouReportID?: string, allReportTransactions?: Transaction[]): boolean { const transactionsByIouReportID = getReportTransactions(iouReportID); const reportTransactions = allReportTransactions ?? transactionsByIouReportID; From 3d86db59bfd9e86bbc92f1c49294a384c376acba Mon Sep 17 00:00:00 2001 From: dmkt9 Date: Mon, 24 Nov 2025 23:14:37 +0700 Subject: [PATCH 6/6] fix lint --- src/libs/ReportUtils.ts | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 7cca19eb70b2..90571ffb883e 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -75,7 +75,6 @@ import type {NotificationPreference, Participants, Participant as ReportParticip import type {Message, OldDotReportAction, ReportActions} from '@src/types/onyx/ReportAction'; import type {PendingChatMember} from '@src/types/onyx/ReportMetadata'; import type {OnyxData} from '@src/types/onyx/Request'; -import type {SearchTransaction} from '@src/types/onyx/SearchResults'; import type {Comment, TransactionChanges, WaypointCollection} from '@src/types/onyx/Transaction'; import type {FileObject} from '@src/types/utils/Attachment'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; @@ -929,7 +928,7 @@ type GetReportNameParams = { parentReportActionParam?: OnyxInputOrEntry; personalDetails?: Partial; invoiceReceiverPolicy?: OnyxEntry; - transactions?: SearchTransaction[]; + transactions?: Transaction[]; reports?: Report[]; policies?: Policy[]; isReportArchived?: boolean; @@ -4981,7 +4980,7 @@ function getTransactionReportName({ reports, }: { reportAction: OnyxEntry; - transactions?: SearchTransaction[]; + transactions?: Transaction[]; reports?: Report[]; }): string { if (isReversedTransaction(reportAction)) { @@ -5611,7 +5610,7 @@ function getReportName( personalDetails?: Partial, invoiceReceiverPolicy?: OnyxEntry, reportAttributes?: ReportAttributesDerivedValue['reports'], - transactions?: SearchTransaction[], + transactions?: Transaction[], isReportArchived?: boolean, reports?: Report[], policies?: Policy[], @@ -8940,7 +8939,7 @@ function hasViolations( reportID: string | undefined, transactionViolations: OnyxCollection, shouldShowInReview?: boolean, - reportTransactions?: SearchTransaction[], + reportTransactions?: Transaction[], ): boolean { const transactions = reportTransactions ?? getReportTransactions(reportID); return transactions.some((transaction) => hasViolation(transaction, transactionViolations, shouldShowInReview)); @@ -8953,7 +8952,7 @@ function hasWarningTypeViolations( reportID: string | undefined, transactionViolations: OnyxCollection, shouldShowInReview?: boolean, - reportTransactions?: SearchTransaction[], + reportTransactions?: Transaction[], ): boolean { const transactions = reportTransactions ?? getReportTransactions(reportID); return transactions.some((transaction) => hasWarningTypeViolation(transaction, transactionViolations, shouldShowInReview)); @@ -8986,7 +8985,7 @@ function hasNoticeTypeViolations( reportID: string | undefined, transactionViolations: OnyxCollection, shouldShowInReview?: boolean, - reportTransactions?: SearchTransaction[], + reportTransactions?: Transaction[], ): boolean { const transactions = reportTransactions ?? getReportTransactions(reportID); return transactions.some((transaction) => hasNoticeTypeViolation(transaction, transactionViolations, shouldShowInReview)); @@ -8995,7 +8994,7 @@ function hasNoticeTypeViolations( /** * Checks to see if a report contains any type of violation */ -function hasAnyViolations(reportID: string | undefined, transactionViolations: OnyxCollection, reportTransactions?: SearchTransaction[]) { +function hasAnyViolations(reportID: string | undefined, transactionViolations: OnyxCollection, reportTransactions?: Transaction[]) { return ( hasViolations(reportID, transactionViolations, undefined, reportTransactions) || hasNoticeTypeViolations(reportID, transactionViolations, true, reportTransactions) || @@ -9019,12 +9018,12 @@ function shouldBlockSubmitDueToStrictPolicyRules( reportID: string | undefined, transactionViolations: OnyxCollection, areStrictPolicyRulesEnabled: boolean, - reportTransactions?: Transaction[] | SearchTransaction[], + reportTransactions?: Transaction[], ) { if (!areStrictPolicyRulesEnabled) { return false; } - return hasAnyViolations(reportID, transactionViolations, reportTransactions as SearchTransaction[]); + return hasAnyViolations(reportID, transactionViolations, reportTransactions); } type ReportErrorsAndReportActionThatRequiresAttention = { @@ -10377,7 +10376,7 @@ function getAllHeldTransactions(iouReportID?: string): Transaction[] { /** * Check if Report has any held expenses */ -function hasHeldExpenses(iouReportID?: string, allReportTransactions?: SearchTransaction[]): boolean { +function hasHeldExpenses(iouReportID?: string, allReportTransactions?: Transaction[]): boolean { const iouReportTransactions = getReportTransactions(iouReportID); const transactions = allReportTransactions ?? iouReportTransactions; return transactions.some((transaction) => isOnHoldTransactionUtils(transaction)); @@ -10386,7 +10385,7 @@ function hasHeldExpenses(iouReportID?: string, allReportTransactions?: SearchTra /** * Check if all expenses in the Report are on hold */ -function hasOnlyHeldExpenses(iouReportID?: string, allReportTransactions?: SearchTransaction[]): boolean { +function hasOnlyHeldExpenses(iouReportID?: string, allReportTransactions?: Transaction[]): boolean { const transactionsByIouReportID = getReportTransactions(iouReportID); const reportTransactions = allReportTransactions ?? transactionsByIouReportID; return reportTransactions.length > 0 && !reportTransactions.some((transaction) => !isOnHoldTransactionUtils(transaction));