Skip to content

Commit

Permalink
New beta
Browse files Browse the repository at this point in the history
  • Loading branch information
pecanoro committed Jun 17, 2024
1 parent 73569e7 commit d070ad4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
6 changes: 6 additions & 0 deletions src/libs/Permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ function canUseViolations(betas: OnyxEntry<Beta[]>): boolean {
return !!betas?.includes(CONST.BETAS.VIOLATIONS) || canUseAllBetas(betas);
}

function canUseDupeDetection(betas: OnyxEntry<Beta[]>): boolean {
return !!betas?.includes(CONST.BETAS.DUPE_DETECTION) || canUseAllBetas(betas);
}


function canUseP2PDistanceRequests(betas: OnyxEntry<Beta[]>, 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;
Expand Down Expand Up @@ -56,6 +61,7 @@ export default {
canUseDefaultRooms,
canUseLinkPreviews,
canUseViolations,
canUseDupeDetection,
canUseReportFields,
canUseP2PDistanceRequests,
canUseWorkflowsDelayedSubmission,
Expand Down
5 changes: 5 additions & 0 deletions src/libs/TransactionUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Transaction> = {};
Onyx.connect({
Expand Down Expand Up @@ -640,6 +641,10 @@ function getRecentTransactions(transactions: Record<string, string>, 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,
);
Expand Down

0 comments on commit d070ad4

Please sign in to comment.