@@ -89,6 +89,15 @@ type MoneyRequestViewPropsWithoutTransaction = MoneyRequestViewOnyxPropsWithoutT
89
89
90
90
type MoneyRequestViewProps = MoneyRequestViewTransactionOnyxProps & MoneyRequestViewPropsWithoutTransaction ;
91
91
92
+ const receiptImageViolationNames : OnyxTypes . ViolationName [ ] = [
93
+ CONST . VIOLATIONS . RECEIPT_REQUIRED ,
94
+ CONST . VIOLATIONS . RECEIPT_NOT_SMART_SCANNED ,
95
+ CONST . VIOLATIONS . CASH_EXPENSE_WITH_NO_RECEIPT ,
96
+ CONST . VIOLATIONS . SMARTSCAN_FAILED ,
97
+ ] ;
98
+
99
+ const receiptFieldViolationNames : OnyxTypes . ViolationName [ ] = [ CONST . VIOLATIONS . MODIFIED_AMOUNT , CONST . VIOLATIONS . MODIFIED_DATE ] ;
100
+
92
101
const deleteTransaction = ( parentReport : OnyxEntry < OnyxTypes . Report > , parentReportAction : OnyxEntry < OnyxTypes . ReportAction > ) => {
93
102
if ( ! parentReportAction ) {
94
103
return ;
@@ -374,14 +383,24 @@ function MoneyRequestView({
374
383
const isReceiptAllowed = ! isPaidReport && ! isInvoice ;
375
384
const shouldShowReceiptEmptyState =
376
385
isReceiptAllowed && ! hasReceipt && ! isApproved && ! isSettled && ( canEditReceipt || isAdmin || isApprover ) && ( canEditReceipt || ReportUtils . isPaidGroupPolicy ( report ) ) ;
377
- const receiptViolationNames : OnyxTypes . ViolationName [ ] = [
378
- CONST . VIOLATIONS . RECEIPT_REQUIRED ,
379
- CONST . VIOLATIONS . RECEIPT_NOT_SMART_SCANNED ,
380
- CONST . VIOLATIONS . CASH_EXPENSE_WITH_NO_RECEIPT ,
381
- CONST . VIOLATIONS . SMARTSCAN_FAILED ,
382
- ] ;
383
- const receiptViolations =
384
- transactionViolations ?. filter ( ( violation ) => receiptViolationNames . includes ( violation . name ) ) . map ( ( violation ) => ViolationsUtils . getViolationTranslation ( violation , translate ) ) ?? [ ] ;
386
+
387
+ const [ receiptImageViolations , receiptViolations ] = useMemo ( ( ) => {
388
+ const imageViolations = [ ] ;
389
+ const allViolations = [ ] ;
390
+
391
+ for ( const violation of transactionViolations ?? [ ] ) {
392
+ const isReceiptFieldViolation = receiptFieldViolationNames . includes ( violation . name ) ;
393
+ const isReceiptImageViolation = receiptImageViolationNames . includes ( violation . name ) ;
394
+ if ( isReceiptFieldViolation || isReceiptImageViolation ) {
395
+ const violationMessage = ViolationsUtils . getViolationTranslation ( violation , translate ) ;
396
+ allViolations . push ( violationMessage ) ;
397
+ if ( isReceiptImageViolation ) {
398
+ imageViolations . push ( violationMessage ) ;
399
+ }
400
+ }
401
+ }
402
+ return [ imageViolations , allViolations ] ;
403
+ } , [ transactionViolations , translate ] ) ;
385
404
386
405
// Whether to show receipt audit result (e.g.`Verified`, `Issue Found`) and messages (e.g. `Receipt not verified. Please confirm accuracy.`)
387
406
// `!!(receiptViolations.length || didReceiptScanSucceed)` is for not showing `Verified` when `receiptViolations` is empty and `didReceiptScanSucceed` is false.
@@ -498,7 +517,7 @@ function MoneyRequestView({
498
517
/>
499
518
) }
500
519
{ ! shouldShowReceiptEmptyState && ! hasReceipt && < View style = { { marginVertical : 6 } } /> }
501
- { shouldShowAuditMessage && < ReceiptAuditMessages notes = { receiptViolations } /> }
520
+ { shouldShowAuditMessage && < ReceiptAuditMessages notes = { receiptImageViolations } /> }
502
521
< OfflineWithFeedback pendingAction = { getPendingFieldAction ( 'amount' ) } >
503
522
< MenuItemWithTopDescription
504
523
title = { amountTitle }
0 commit comments