-
Notifications
You must be signed in to change notification settings - Fork 3.7k
feat: surfacing potential duplicates #40153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b7cdaf8
513909a
473adaa
9aba989
369585f
3843a61
20b4048
38c9188
4a6a285
462b3df
fd8e18c
7e2d605
870b6ac
7c3136f
e68f9f1
3d844a0
4947382
bd6693b
5e558a8
22b6cd9
edafa52
8185218
1e7acb4
795dc56
951daeb
742c12d
fc07750
2c425b5
796e531
f934be5
1060cc7
10535a6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,6 +40,16 @@ Onyx.connect({ | |
| callback: (value) => (allReports = value), | ||
| }); | ||
|
|
||
| let currentUserEmail = ''; | ||
| let currentUserAccountID = -1; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.SESSION, | ||
| callback: (val) => { | ||
| currentUserEmail = val?.email ?? ''; | ||
| currentUserAccountID = val?.accountID ?? -1; | ||
| }, | ||
| }); | ||
|
|
||
| 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')) { | ||
|
|
@@ -623,6 +633,23 @@ function getRecentTransactions(transactions: Record<string, string>, size = 2): | |
| .slice(0, size); | ||
| } | ||
|
|
||
| /** | ||
| * Check if transaction has duplicatedTransaction violation. | ||
| * @param transactionID - the transaction to check | ||
| * @param checkDismissed - whether to check if the violation has already been dismissed as well | ||
| */ | ||
| function isDuplicate(transactionID: string, checkDismissed = false): boolean { | ||
| const hasDuplicatedViolation = !!allTransactionViolations?.[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`]?.some( | ||
| (violation: TransactionViolation) => violation.name === CONST.VIOLATIONS.DUPLICATED_TRANSACTION, | ||
| ); | ||
| if (!checkDismissed) { | ||
| return hasDuplicatedViolation; | ||
| } | ||
| const didDismissedViolation = | ||
| allTransactions?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`]?.comment?.dismissedViolations?.duplicatedTransaction?.[currentUserEmail] === `${currentUserAccountID}`; | ||
|
Comment on lines
+648
to
+649
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Coming from #66181, From the OP "Feature Description" screenshots, BE is returning the
|
||
| return hasDuplicatedViolation && !didDismissedViolation; | ||
| } | ||
|
|
||
| /** | ||
| * Check if transaction is on hold | ||
| */ | ||
|
|
@@ -631,7 +658,7 @@ function isOnHold(transaction: OnyxEntry<Transaction>): boolean { | |
| return false; | ||
| } | ||
|
|
||
| return !!transaction.comment?.hold; | ||
| return !!transaction.comment?.hold || isDuplicate(transaction.transactionID, true); | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add |
||
|
|
||
| /** | ||
|
|
@@ -661,6 +688,15 @@ function hasNoticeTypeViolation(transactionID: string, transactionViolations: On | |
| return Boolean(transactionViolations?.[ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS + transactionID]?.some((violation: TransactionViolation) => violation.type === 'notice')); | ||
| } | ||
|
|
||
| /** | ||
| * Checks if any violations for the provided transaction are of type 'warning' | ||
| */ | ||
| function hasWarningTypeViolation(transactionID: string, transactionViolations: OnyxCollection<TransactionViolation[]>): boolean { | ||
| return Boolean( | ||
| transactionViolations?.[ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS + transactionID]?.some((violation: TransactionViolation) => violation.type === CONST.VIOLATION_TYPES.WARNING), | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * Calculates tax amount from the given expense amount and tax percentage | ||
| */ | ||
|
|
@@ -798,6 +834,7 @@ export { | |
| isFetchingWaypointsFromServer, | ||
| isExpensifyCardTransaction, | ||
| isCardTransaction, | ||
| isDuplicate, | ||
| isPending, | ||
| isPosted, | ||
| isOnHold, | ||
|
|
@@ -818,6 +855,7 @@ export { | |
| hasReservationList, | ||
| hasViolation, | ||
| hasNoticeTypeViolation, | ||
| hasWarningTypeViolation, | ||
| isCustomUnitRateIDForP2P, | ||
| getRateID, | ||
| }; | ||
|
|
||

Uh oh!
There was an error while loading. Please reload this page.