@@ -902,27 +902,99 @@ describe('PureReportActionItem', () => {
902902 expect ( screen . getByText ( translateLocal ( translationKey ) ) ) . toBeOnTheScreen ( ) ;
903903 } ) ;
904904
905- it ( 'RECEIPT_SCAN_FAILED action shows message from action data' , async ( ) => {
906- // Given a RECEIPT_SCAN_FAILED message with a html message from server.
907- // Then verify server message is rendered.
905+ it ( 'RECEIPT_SCAN_FAILED action shows submitter message when current user is the expense submitter' , async ( ) => {
906+ const parentReportID = 'parentReport1' ;
907+ const parentReportActionID = 'iouAction1' ;
908+
909+ await act ( async ( ) => {
910+ await Onyx . merge ( ONYXKEYS . SESSION , { accountID : ACTOR_ACCOUNT_ID } ) ;
911+ await Onyx . merge ( `${ ONYXKEYS . COLLECTION . REPORT_ACTIONS } ${ parentReportID } ` , {
912+ [ parentReportActionID ] : {
913+ reportActionID : parentReportActionID ,
914+ actorAccountID : ACTOR_ACCOUNT_ID ,
915+ actionName : CONST . REPORT . ACTIONS . TYPE . IOU ,
916+ created : '2025-07-12 09:03:17.653' ,
917+ message : [ { type : 'COMMENT' , html : '' , text : '' } ] ,
918+ originalMessage : { type : CONST . IOU . REPORT_ACTION_TYPE . CREATE , amount : 100 , currency : 'USD' } ,
919+ } ,
920+ } ) ;
921+ } ) ;
922+ await waitForBatchedUpdatesWithAct ( ) ;
923+
924+ const report = { reportID : 'scanReport1' , parentReportID, parentReportActionID} ;
908925 const action = createReportAction ( CONST . REPORT . ACTIONS . TYPE . RECEIPT_SCAN_FAILED , { } ) ;
909- action . message = [
910- {
911- type : 'COMMENT' ,
912- html : "the date couldn't be read from this receipt. Please enter it manually." ,
913- text : "the date couldn't be read from this receipt. Please enter it manually." ,
914- } ,
915- ] ;
916- renderItemWithAction ( action ) ;
926+
927+ render (
928+ < ComposeProviders components = { [ OnyxListItemProvider , LocaleContextProvider , HTMLEngineProvider ] } >
929+ < OptionsListContextProvider >
930+ < ScreenWrapper testID = "test" >
931+ < PortalProvider >
932+ < PureReportActionItem
933+ personalPolicyID = { undefined }
934+ report = { report }
935+ parentReportAction = { undefined }
936+ action = { action }
937+ displayAsGroup = { false }
938+ shouldDisplayNewMarker = { false }
939+ index = { 0 }
940+ isFirstVisibleReportAction = { false }
941+ />
942+ </ PortalProvider >
943+ </ ScreenWrapper >
944+ </ OptionsListContextProvider >
945+ </ ComposeProviders > ,
946+ ) ;
917947 await waitForBatchedUpdatesWithAct ( ) ;
918- expect ( screen . getByText ( "the date couldn't be read from this receipt. Please enter it manually." ) ) . toBeOnTheScreen ( ) ;
919948
920- // Given an RECEIPT_SCAN_FAILED with no server side message
921- // Then verify generic translation phrase is rendered
922- action . message = [ { type : 'COMMENT' , html : '' , text : '' } ] ;
923- renderItemWithAction ( action ) ;
949+ expect ( screen . getByText ( translateLocal ( 'violations.smartscanFailed' , { canEdit : true } ) ) ) . toBeOnTheScreen ( ) ;
950+ } ) ;
951+
952+ it ( 'RECEIPT_SCAN_FAILED action shows non-submitter message when current user is not the expense submitter' , async ( ) => {
953+ const parentReportID = 'parentReport2' ;
954+ const parentReportActionID = 'iouAction2' ;
955+ const OTHER_ACCOUNT_ID = 999999 ;
956+
957+ await act ( async ( ) => {
958+ await Onyx . merge ( ONYXKEYS . SESSION , { accountID : ACTOR_ACCOUNT_ID } ) ;
959+ await Onyx . merge ( `${ ONYXKEYS . COLLECTION . REPORT_ACTIONS } ${ parentReportID } ` , {
960+ [ parentReportActionID ] : {
961+ reportActionID : parentReportActionID ,
962+ actorAccountID : OTHER_ACCOUNT_ID ,
963+ actionName : CONST . REPORT . ACTIONS . TYPE . IOU ,
964+ created : '2025-07-12 09:03:17.653' ,
965+ message : [ { type : 'COMMENT' , html : '' , text : '' } ] ,
966+ originalMessage : { type : CONST . IOU . REPORT_ACTION_TYPE . CREATE , amount : 100 , currency : 'USD' } ,
967+ } ,
968+ } ) ;
969+ } ) ;
970+ await waitForBatchedUpdatesWithAct ( ) ;
971+
972+ const report = { reportID : 'scanReport2' , parentReportID, parentReportActionID} ;
973+ const action = createReportAction ( CONST . REPORT . ACTIONS . TYPE . RECEIPT_SCAN_FAILED , { } ) ;
974+
975+ render (
976+ < ComposeProviders components = { [ OnyxListItemProvider , LocaleContextProvider , HTMLEngineProvider ] } >
977+ < OptionsListContextProvider >
978+ < ScreenWrapper testID = "test" >
979+ < PortalProvider >
980+ < PureReportActionItem
981+ personalPolicyID = { undefined }
982+ report = { report }
983+ parentReportAction = { undefined }
984+ action = { action }
985+ displayAsGroup = { false }
986+ shouldDisplayNewMarker = { false }
987+ index = { 0 }
988+ isFirstVisibleReportAction = { false }
989+ />
990+ </ PortalProvider >
991+ </ ScreenWrapper >
992+ </ OptionsListContextProvider >
993+ </ ComposeProviders > ,
994+ ) ;
924995 await waitForBatchedUpdatesWithAct ( ) ;
925- expect ( screen . getByText ( translateLocal ( 'iou.receiptScanningFailed' ) ) ) . toBeOnTheScreen ( ) ;
996+
997+ expect ( screen . getByText ( translateLocal ( 'violations.smartscanFailed' , { canEdit : false } ) ) ) . toBeOnTheScreen ( ) ;
926998 } ) ;
927999
9281000 it ( 'HOLD_COMMENT action renders via ReportActionItemBasicMessage' , async ( ) => {
0 commit comments