@@ -895,6 +895,119 @@ describe('ReportNameUtils', () => {
895895 expect ( name ) . toBe ( 'changed the "Office Supplies" category default tax rate to "Tax Rate 1 (5%)" (previously "Tax Exempt (0%)")' ) ;
896896 } ) ;
897897
898+ test . each ( [
899+ [ CONST . REPORT . ACTIONS . TYPE . POLICY_CHANGE_LOG . ADD_CATEGORY , { categoryName : 'Advertising' } , 'added the category "Advertising"' ] ,
900+ [ CONST . REPORT . ACTIONS . TYPE . POLICY_CHANGE_LOG . DELETE_CATEGORY , { categoryName : 'Advertising' } , 'removed the category "Advertising"' ] ,
901+ [
902+ CONST . REPORT . ACTIONS . TYPE . POLICY_CHANGE_LOG . UPDATE_CATEGORY ,
903+ { categoryName : 'Advertising' , updatedField : 'areAttendeesRequired' , oldValue : '' , newValue : true } ,
904+ 'changed the "Advertising" category attendees to required (previously not required)' ,
905+ ] ,
906+ [ CONST . REPORT . ACTIONS . TYPE . POLICY_CHANGE_LOG . SET_CATEGORY_NAME , { oldName : 'Advertising' , newName : 'Marketing' } , 'renamed the category "Advertising" to "Marketing"' ] ,
907+ ] ) ( '%s parent action renders the same message as the system message in the chat' , ( actionName , originalMessage , expected ) => {
908+ const thread : Report = createWorkspaceThread ( 161 ) ;
909+ const parentAction = createMock < ReportAction > ( {
910+ actionName,
911+ reportActionID : String ( thread . parentReportActionID ) ,
912+ message : [ ] ,
913+ created : '' ,
914+ lastModified : '' ,
915+ actorAccountID : 1 ,
916+ person : [ ] ,
917+ originalMessage,
918+ } ) ;
919+
920+ const reportActionsCollection : Record < string , ReportActions > = {
921+ [ `${ ONYXKEYS . COLLECTION . REPORT_ACTIONS } ${ String ( thread . parentReportID ) } ` ] : {
922+ [ String ( thread . parentReportActionID ) ] : parentAction ,
923+ } ,
924+ } ;
925+
926+ const name = computeReportName (
927+ thread ,
928+ emptyCollections . reports ,
929+ emptyCollections . policies ,
930+ undefined ,
931+ undefined ,
932+ participantsPersonalDetails ,
933+ reportActionsCollection ,
934+ currentUserAccountID ,
935+ ) ;
936+ expect ( name ) . toBe ( expected ) ;
937+ } ) ;
938+
939+ test ( 'UPDATE_CATEGORY parent action renders the description hint as plain text' , ( ) => {
940+ const thread : Report = createWorkspaceThread ( 163 ) ;
941+ const parentAction = createMock < ReportAction > ( {
942+ actionName : CONST . REPORT . ACTIONS . TYPE . POLICY_CHANGE_LOG . UPDATE_CATEGORY ,
943+ reportActionID : String ( thread . parentReportActionID ) ,
944+ message : [ ] ,
945+ created : '' ,
946+ lastModified : '' ,
947+ actorAccountID : 1 ,
948+ person : [ ] ,
949+ originalMessage : {
950+ categoryName : 'Advertising' ,
951+ updatedField : 'commentHint' ,
952+ oldValue : '' ,
953+ newValue : 'Client's & partner's names' ,
954+ } ,
955+ } ) ;
956+
957+ const reportActionsCollection : Record < string , ReportActions > = {
958+ [ `${ ONYXKEYS . COLLECTION . REPORT_ACTIONS } ${ String ( thread . parentReportID ) } ` ] : {
959+ [ String ( thread . parentReportActionID ) ] : parentAction ,
960+ } ,
961+ } ;
962+
963+ const name = computeReportName (
964+ thread ,
965+ emptyCollections . reports ,
966+ emptyCollections . policies ,
967+ undefined ,
968+ undefined ,
969+ participantsPersonalDetails ,
970+ reportActionsCollection ,
971+ currentUserAccountID ,
972+ ) ;
973+ expect ( name ) . toBe ( `added the description hint "Client's & partner's names" to the category "Advertising"` ) ;
974+ } ) ;
975+
976+ test ( 'UPDATE_CATEGORY parent action formats the workspace default receipt amount with the policy currency' , ( ) => {
977+ const thread : Report = createWorkspaceThread ( 162 ) ;
978+ const parentAction = createMock < ReportAction > ( {
979+ actionName : CONST . REPORT . ACTIONS . TYPE . POLICY_CHANGE_LOG . UPDATE_CATEGORY ,
980+ reportActionID : String ( thread . parentReportActionID ) ,
981+ message : [ ] ,
982+ created : '' ,
983+ lastModified : '' ,
984+ actorAccountID : 1 ,
985+ person : [ ] ,
986+ originalMessage : {
987+ categoryName : 'Advertising' ,
988+ updatedField : 'maxAmountNoReceipt' ,
989+ oldValue : 0 ,
990+ newValue : '' ,
991+ } ,
992+ } ) ;
993+
994+ const reportActionsCollection : Record < string , ReportActions > = {
995+ [ `${ ONYXKEYS . COLLECTION . REPORT_ACTIONS } ${ String ( thread . parentReportID ) } ` ] : {
996+ [ String ( thread . parentReportActionID ) ] : parentAction ,
997+ } ,
998+ } ;
999+ const policies : OnyxCollection < Policy > = {
1000+ [ `${ ONYXKEYS . COLLECTION . POLICY } ${ String ( thread . policyID ) } ` ] : createMock < Policy > ( {
1001+ id : String ( thread . policyID ) ,
1002+ maxExpenseAmountNoReceipt : 5000 ,
1003+ outputCurrency : 'EUR' ,
1004+ } ) ,
1005+ } ;
1006+
1007+ const name = computeReportName ( thread , emptyCollections . reports , policies , undefined , undefined , participantsPersonalDetails , reportActionsCollection , currentUserAccountID ) ;
1008+ expect ( name ) . toBe ( 'changed the "Advertising" category to €50 • Default (previously Always require receipts)' ) ;
1009+ } ) ;
1010+
8981011 test ( 'DELETE_CARD_FEED parent action' , ( ) => {
8991012 const thread : Report = createWorkspaceThread ( 101 ) ;
9001013 const parentAction = createMock < ReportAction > ( {
0 commit comments