diff --git a/src/libs/TransactionUtils.ts b/src/libs/TransactionUtils.ts index 66fc196cbb16..6a4d3533353b 100644 --- a/src/libs/TransactionUtils.ts +++ b/src/libs/TransactionUtils.ts @@ -14,6 +14,7 @@ import * as Localize from './Localize'; import * as NumberUtils from './NumberUtils'; import {getCleanedTagName, getCustomUnitRate} from './PolicyUtils'; import Permissions from "@libs/Permissions"; +import {Beta} from "@src/types/onyx"; let allTransactions: OnyxCollection = {}; Onyx.connect({ @@ -51,6 +52,12 @@ Onyx.connect({ }, }); +let allBetas: OnyxEntry; +Onyx.connect({ + key: ONYXKEYS.BETAS, + callback: (value) => (allBetas = value), +}); + function isDistanceRequest(transaction: OnyxEntry): boolean { // This is used during the expense creation flow before the transaction has been saved to the server if (lodashHas(transaction, 'iouRequestType')) { @@ -641,7 +648,7 @@ function getRecentTransactions(transactions: Record, size = 2): * @param checkDismissed - whether to check if the violation has already been dismissed as well */ function isDuplicate(transactionID: string, checkDismissed = false): boolean { - if (Permissions.canUseDupeDetection(allBetas ?? [])) { + if (!Permissions.canUseDupeDetection(allBetas ?? [])) { return false; } @@ -698,6 +705,10 @@ function hasNoticeTypeViolation(transactionID: string, transactionViolations: On * Checks if any violations for the provided transaction are of type 'warning' */ function hasWarningTypeViolation(transactionID: string, transactionViolations: OnyxCollection): boolean { + if (!Permissions.canUseDupeDetection(allBetas ?? [])) { + return false; + } + return !!transactionViolations?.[ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS + transactionID]?.some((violation: TransactionViolation) => violation.type === CONST.VIOLATION_TYPES.WARNING); }