Skip to content

Commit

Permalink
Check for message
Browse files Browse the repository at this point in the history
  • Loading branch information
pecanoro committed Jun 17, 2024
1 parent d070ad4 commit 3c7d2f7
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/libs/TransactionUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import * as Localize from './Localize';
import * as NumberUtils from './NumberUtils';
import {getCleanedTagName, getCustomUnitRate} from './PolicyUtils';
import Permissions from "@libs/Permissions";

Check warning on line 16 in src/libs/TransactionUtils.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unexpected subpath import via alias '@libs/Permissions'. Use './Permissions' instead

Check failure on line 16 in src/libs/TransactionUtils.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

`@libs/Permissions` import should occur before type import of `./actions/IOU`
import {Beta} from "@src/types/onyx";

Check failure on line 17 in src/libs/TransactionUtils.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

All imports in the declaration are only used as types. Use `import type`

Check failure on line 17 in src/libs/TransactionUtils.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

`@src/types/onyx` import should occur before type import of `./actions/IOU`

let allTransactions: OnyxCollection<Transaction> = {};
Onyx.connect({
Expand Down Expand Up @@ -51,6 +52,12 @@ Onyx.connect({
},
});

let allBetas: OnyxEntry<Beta[]>;
Onyx.connect({
key: ONYXKEYS.BETAS,
callback: (value) => (allBetas = value),
});

function isDistanceRequest(transaction: OnyxEntry<Transaction>): boolean {
// This is used during the expense creation flow before the transaction has been saved to the server
if (lodashHas(transaction, 'iouRequestType')) {
Expand Down Expand Up @@ -641,7 +648,7 @@ 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 ?? [])) {
if (!Permissions.canUseDupeDetection(allBetas ?? [])) {
return false;
}

Expand Down Expand Up @@ -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<TransactionViolation[]>): boolean {
if (!Permissions.canUseDupeDetection(allBetas ?? [])) {
return false;
}

return !!transactionViolations?.[ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS + transactionID]?.some((violation: TransactionViolation) => violation.type === CONST.VIOLATION_TYPES.WARNING);
}

Expand Down

0 comments on commit 3c7d2f7

Please sign in to comment.