@@ -130,11 +130,17 @@ function getViolationTranslatePath(violations: OnyxTypes.TransactionViolations,
130130 * it returns an empty array. It identifies the latest error in each action and filters out duplicates to
131131 * ensure only unique error messages are returned.
132132 */
133- function getUniqueActionErrors ( reportActions : OnyxTypes . ReportActions ) {
133+ function getUniqueActionErrors ( reportActions : OnyxTypes . ReportActions , transaction : OnyxTypes . Transaction | undefined ) {
134134 const reportErrors = Object . values ( reportActions ) . map ( ( reportAction ) => {
135135 const errors = reportAction . errors ?? { } ;
136136 const key = Object . keys ( errors ) . sort ( ) . reverse ( ) . at ( 0 ) ?? '' ;
137137 const error = errors [ key ] ;
138+ if ( isMoneyRequestAction ( reportAction ) && getOriginalMessage ( reportAction ) ?. IOUTransactionID ) {
139+ if ( getOriginalMessage ( reportAction ) ?. IOUTransactionID === transaction ?. transactionID ) {
140+ return typeof error === 'string' ? error : '' ;
141+ }
142+ return '' ;
143+ }
138144 return typeof error === 'string' ? error : '' ;
139145 } ) ;
140146
@@ -175,7 +181,7 @@ function getTransactionPreviewTextAndTranslationPaths({
175181 const isTransactionScanning = isScanning ( transaction ) ;
176182 const hasFieldErrors = hasMissingSmartscanFields ( transaction ) ;
177183 const hasViolationsOfTypeNotice = hasNoticeTypeViolation ( transaction , violations , true ) && isPaidGroupPolicy ( iouReport ) ;
178- const hasActionWithErrors = hasActionsWithErrors ( iouReport ?. reportID ) ;
184+ const hasActionWithErrors = hasActionsWithErrors ( iouReport ?. reportID , transaction ) ;
179185
180186 const { amount : requestAmount , currency : requestCurrency } = transactionDetails ;
181187
@@ -207,7 +213,7 @@ function getTransactionPreviewTextAndTranslationPaths({
207213 }
208214
209215 if ( RBRMessage === undefined && hasActionWithErrors && ! ! reportActions ) {
210- const actionsWithErrors = getUniqueActionErrors ( reportActions ) ;
216+ const actionsWithErrors = getUniqueActionErrors ( reportActions , transaction ) ;
211217 RBRMessage = actionsWithErrors . length > 1 ? { translationPath : 'violations.reviewRequired' } : { text : actionsWithErrors . at ( 0 ) } ;
212218 }
213219
@@ -330,7 +336,7 @@ function createTransactionPreviewConditionals({
330336 hasWarningTypeViolation ( transaction , violations , true ) ||
331337 hasViolation ( transaction , violations , true ) ;
332338 const hasErrorOrOnHold = hasFieldErrors || ( ! isFullySettled && ! isFullyApproved && isTransactionOnHold ) ;
333- const hasReportViolationsOrActionErrors = ( isReportOwner ( iouReport ) && hasReportViolations ( iouReport ?. reportID ) ) || hasActionsWithErrors ( iouReport ?. reportID ) ;
339+ const hasReportViolationsOrActionErrors = ( isReportOwner ( iouReport ) && hasReportViolations ( iouReport ?. reportID ) ) || hasActionsWithErrors ( iouReport ?. reportID , transaction ) ;
334340 const shouldShowRBR = hasAnyViolations || hasErrorOrOnHold || hasReportViolationsOrActionErrors ;
335341
336342 // When there are no settled transactions in duplicates, show the "Keep this one" button
0 commit comments