From d070ad48c48b166461ee8f45b69b3d6dd22f2d53 Mon Sep 17 00:00:00 2001 From: Rocio Perez-Cano Date: Mon, 17 Jun 2024 16:13:04 -0400 Subject: [PATCH] New beta --- src/CONST.ts | 1 + src/libs/Permissions.ts | 6 ++++++ src/libs/TransactionUtils.ts | 5 +++++ 3 files changed, 12 insertions(+) diff --git a/src/CONST.ts b/src/CONST.ts index 9311816c38a2..6b9e033cdd4b 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -356,6 +356,7 @@ const CONST = { CHRONOS_IN_CASH: 'chronosInCash', DEFAULT_ROOMS: 'defaultRooms', VIOLATIONS: 'violations', + DUPE_DETECTION: 'dupeDetection', REPORT_FIELDS: 'reportFields', P2P_DISTANCE_REQUESTS: 'p2pDistanceRequests', WORKFLOWS_DELAYED_SUBMISSION: 'workflowsDelayedSubmission', diff --git a/src/libs/Permissions.ts b/src/libs/Permissions.ts index 45551fe1cad9..ee44af82f7da 100644 --- a/src/libs/Permissions.ts +++ b/src/libs/Permissions.ts @@ -23,6 +23,11 @@ function canUseViolations(betas: OnyxEntry): boolean { return !!betas?.includes(CONST.BETAS.VIOLATIONS) || canUseAllBetas(betas); } +function canUseDupeDetection(betas: OnyxEntry): boolean { + return !!betas?.includes(CONST.BETAS.DUPE_DETECTION) || canUseAllBetas(betas); +} + + function canUseP2PDistanceRequests(betas: OnyxEntry, iouType: IOUType | undefined): boolean { // Allow using P2P distance request for TrackExpense outside of the beta, because that project doesn't want to be limited by the more cautious P2P distance beta return !!betas?.includes(CONST.BETAS.P2P_DISTANCE_REQUESTS) || canUseAllBetas(betas) || iouType === CONST.IOU.TYPE.TRACK; @@ -56,6 +61,7 @@ export default { canUseDefaultRooms, canUseLinkPreviews, canUseViolations, + canUseDupeDetection, canUseReportFields, canUseP2PDistanceRequests, canUseWorkflowsDelayedSubmission, diff --git a/src/libs/TransactionUtils.ts b/src/libs/TransactionUtils.ts index cfeb866e572f..66fc196cbb16 100644 --- a/src/libs/TransactionUtils.ts +++ b/src/libs/TransactionUtils.ts @@ -13,6 +13,7 @@ import DateUtils from './DateUtils'; import * as Localize from './Localize'; import * as NumberUtils from './NumberUtils'; import {getCleanedTagName, getCustomUnitRate} from './PolicyUtils'; +import Permissions from "@libs/Permissions"; let allTransactions: OnyxCollection = {}; Onyx.connect({ @@ -640,6 +641,10 @@ 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 ?? [])) { + return false; + } + const hasDuplicatedViolation = !!allTransactionViolations?.[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`]?.some( (violation: TransactionViolation) => violation.name === CONST.VIOLATIONS.DUPLICATED_TRANSACTION, );