-
Notifications
You must be signed in to change notification settings - Fork 3k
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
feat: [Auth Violations] Support isDismissed on newDot to hide violations. #54455
Changes from 40 commits
6463ecf
6166bb7
2a179a2
cd59a56
5682ae0
1016065
a2d0da6
ee414e3
82877a6
18f9c6f
40c5559
3f4dd02
7eb5639
593f497
825c4be
969623b
486acb5
0a0cbc3
55f73fa
a5194c8
332efdf
1ef4be5
afe362c
6abedea
05747b2
d870956
2774880
078b3fc
3970b9d
a39a2f5
789b51d
f9e3e7e
93d33a2
156a3aa
d477565
ed89588
79b012f
65cb691
55e01d5
e79c90b
32bf0c8
5e20ecc
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 |
---|---|---|
|
@@ -112,7 +112,8 @@ function MoneyRequestPreviewContent({ | |
const transactionID = isMoneyRequestAction ? getOriginalMessage(action)?.IOUTransactionID : undefined; | ||
const [transaction] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`); | ||
const [walletTerms] = useOnyx(ONYXKEYS.WALLET_TERMS); | ||
const [transactionViolations] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS); | ||
const [allViolations] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS); | ||
const transactionViolations = getTransactionViolations(transaction?.transactionID); | ||
|
||
const sessionAccountID = session?.accountID; | ||
const managerID = iouReport?.managerID ?? CONST.DEFAULT_NUMBER_ID; | ||
|
@@ -145,9 +146,9 @@ function MoneyRequestPreviewContent({ | |
const isOnHold = isOnHoldTransactionUtils(transaction); | ||
const isSettlementOrApprovalPartial = !!iouReport?.pendingFields?.partial; | ||
const isPartialHold = isSettlementOrApprovalPartial && isOnHold; | ||
const hasViolations = hasViolationTransactionUtils(transaction?.transactionID, transactionViolations, true); | ||
const hasNoticeTypeViolations = hasNoticeTypeViolationTransactionUtils(transaction?.transactionID, transactionViolations, true) && isPaidGroupPolicy(iouReport); | ||
const hasWarningTypeViolations = hasWarningTypeViolationTransactionUtils(transaction?.transactionID, transactionViolations, true); | ||
const hasViolations = hasViolationTransactionUtils(transaction?.transactionID, allViolations, true); | ||
const hasNoticeTypeViolations = hasNoticeTypeViolationTransactionUtils(transaction?.transactionID, allViolations, true) && isPaidGroupPolicy(iouReport); | ||
const hasWarningTypeViolations = hasWarningTypeViolationTransactionUtils(transaction?.transactionID, allViolations, true); | ||
const hasFieldErrors = hasMissingSmartscanFields(transaction); | ||
const isDistanceRequest = isDistanceRequestTransactionUtils(transaction); | ||
const isPerDiemRequest = isPerDiemRequestTransactionUtils(transaction); | ||
|
@@ -163,11 +164,8 @@ function MoneyRequestPreviewContent({ | |
|
||
// Get transaction violations for given transaction id from onyx, find duplicated transactions violations and get duplicates | ||
const allDuplicates = useMemo( | ||
() => | ||
transactionViolations?.[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transaction?.transactionID}`]?.find( | ||
(violation) => violation.name === CONST.VIOLATIONS.DUPLICATED_TRANSACTION, | ||
)?.data?.duplicates ?? [], | ||
[transaction?.transactionID, transactionViolations], | ||
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. Don't we have to keep 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.
Just updated the code, now we are using |
||
() => transactionViolations?.find((violation) => violation.name === CONST.VIOLATIONS.DUPLICATED_TRANSACTION)?.data?.duplicates ?? [], | ||
[transactionViolations], | ||
); | ||
|
||
// Remove settled transactions from duplicates | ||
|
@@ -240,14 +238,13 @@ function MoneyRequestPreviewContent({ | |
} | ||
|
||
if (shouldShowRBR && transaction) { | ||
const violations = getTransactionViolations(transaction.transactionID, transactionViolations); | ||
if (shouldShowHoldMessage) { | ||
return `${message} ${CONST.DOT_SEPARATOR} ${translate('violations.hold')}`; | ||
} | ||
const firstViolation = violations?.at(0); | ||
const firstViolation = transactionViolations?.at(0); | ||
if (firstViolation) { | ||
const violationMessage = ViolationsUtils.getViolationTranslation(firstViolation, translate); | ||
const violationsCount = violations?.filter((v) => v.type === CONST.VIOLATION_TYPES.VIOLATION).length ?? 0; | ||
const violationsCount = transactionViolations?.filter((v) => v.type === CONST.VIOLATION_TYPES.VIOLATION).length ?? 0; | ||
const isTooLong = violationsCount > 1 || violationMessage.length > 15; | ||
const hasViolationsAndFieldErrors = violationsCount > 0 && hasFieldErrors; | ||
|
||
|
@@ -287,7 +284,7 @@ function MoneyRequestPreviewContent({ | |
if (shouldShowBrokenConnectionViolation(transaction ? [transaction.transactionID] : [], iouReport, policy)) { | ||
return {shouldShow: true, messageIcon: Expensicons.Hourglass, messageDescription: translate('violations.brokenConnection530Error')}; | ||
} | ||
if (hasPendingUI(transaction, getTransactionViolations(transaction?.transactionID, transactionViolations))) { | ||
if (hasPendingUI(transaction, transactionViolations)) { | ||
return {shouldShow: true, messageIcon: Expensicons.Hourglass, messageDescription: translate('iou.pendingMatchWithCreditCard')}; | ||
} | ||
return {shouldShow: false}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1614,8 +1614,8 @@ function wasActionTakenByCurrentUser(reportAction: OnyxInputOrEntry<ReportAction | |
/** | ||
* Get IOU action for a reportID and transactionID | ||
*/ | ||
function getIOUActionForReportID(reportID: string | undefined, transactionID: string): OnyxEntry<ReportAction> { | ||
if (!reportID) { | ||
function getIOUActionForReportID(reportID: string | undefined, transactionID: string | undefined): OnyxEntry<ReportAction> { | ||
if (!reportID || !transactionID) { | ||
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. @rojiphil, the change is still there. 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. I am referring to the next line where we returned 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. ohh, sorry. Updated. |
||
return; | ||
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. Let's return 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. done 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. @Krishna2323 Why was this reverted? 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. Maybe it was reverted because I tried to simplify solving merge conflicts the change is still there. 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. Can you please add the code back? Otherwise the code LGTM. |
||
} | ||
const report = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let us use
||
instead of??
as that will help address empty strings as well.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use
??
everywhere in the app, otherwise we would need to disable eslint.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it’s fine to leave it as that is the more widely accepted pattern. Maybe this can be taken up later when it is considered in its entirety.