@@ -741,6 +741,50 @@ describe('ReportUtils', () => {
741741 expect ( getReportName ( expenseChatReport ) ) . toEqual ( "Ragnar Lothbrok's expenses" ) ;
742742 } ) ;
743743 } ) ;
744+
745+ describe ( 'Fallback scenarios' , ( ) => {
746+ test ( 'should fallback to report.reportName when primary name generation returns empty string' , ( ) => {
747+ const reportWithFallbackName : Report = {
748+ reportID : '3' ,
749+ reportName : 'Custom Report Name' ,
750+ ownerAccountID : undefined ,
751+ participants : { } ,
752+ policyID : undefined ,
753+ chatType : undefined ,
754+ } ;
755+
756+ const result = getReportName ( reportWithFallbackName ) ;
757+ expect ( result ) . toBe ( 'Custom Report Name' ) ;
758+ } ) ;
759+
760+ test ( 'should return empty string when both primary name generation and reportName are empty' , ( ) => {
761+ const reportWithoutName : Report = {
762+ reportID : '4' ,
763+ reportName : '' ,
764+ ownerAccountID : undefined ,
765+ participants : { } ,
766+ policyID : undefined ,
767+ chatType : undefined ,
768+ } ;
769+
770+ const result = getReportName ( reportWithoutName ) ;
771+ expect ( result ) . toBe ( '' ) ;
772+ } ) ;
773+
774+ test ( 'should return empty string when reportName is undefined' , ( ) => {
775+ const reportWithUndefinedName : Report = {
776+ reportID : '5' ,
777+ reportName : undefined ,
778+ ownerAccountID : undefined ,
779+ participants : { } ,
780+ policyID : undefined ,
781+ chatType : undefined ,
782+ } ;
783+
784+ const result = getReportName ( reportWithUndefinedName ) ;
785+ expect ( result ) . toBe ( '' ) ;
786+ } ) ;
787+ } ) ;
744788 } ) ;
745789
746790 describe ( 'requiresAttentionFromCurrentUser' , ( ) => {
0 commit comments