@@ -4324,6 +4324,7 @@ describe('OptionsListUtils', () => {
43244324 translate : translateLocal ,
43254325 report,
43264326 lastActorDetails : null ,
4327+ policy : undefined ,
43274328 isReportArchived : false ,
43284329 chatReport : undefined ,
43294330 currentUserLogin : CURRENT_USER_EMAIL ,
@@ -4349,6 +4350,7 @@ describe('OptionsListUtils', () => {
43494350 translate : translateLocal ,
43504351 report,
43514352 lastActorDetails : null ,
4353+ policy : undefined ,
43524354 isReportArchived : false ,
43534355 chatReport : undefined ,
43544356 currentUserLogin : CURRENT_USER_EMAIL ,
@@ -4375,6 +4377,7 @@ describe('OptionsListUtils', () => {
43754377 translate : translateLocal ,
43764378 report,
43774379 lastActorDetails : null ,
4380+ policy : undefined ,
43784381 isReportArchived : false ,
43794382 chatReport : undefined ,
43804383 currentUserLogin : CURRENT_USER_EMAIL ,
@@ -4401,6 +4404,7 @@ describe('OptionsListUtils', () => {
44014404 translate : translateLocal ,
44024405 report,
44034406 lastActorDetails : null ,
4407+ policy : undefined ,
44044408 isReportArchived : false ,
44054409 chatReport : undefined ,
44064410 currentUserLogin : CURRENT_USER_EMAIL ,
@@ -4424,6 +4428,7 @@ describe('OptionsListUtils', () => {
44244428 translate : translateLocal ,
44254429 report,
44264430 lastActorDetails : null ,
4431+ policy : undefined ,
44274432 isReportArchived : false ,
44284433 chatReport : undefined ,
44294434 currentUserLogin : CURRENT_USER_EMAIL ,
@@ -4446,6 +4451,7 @@ describe('OptionsListUtils', () => {
44464451 translate : translateLocal ,
44474452 report,
44484453 lastActorDetails : null ,
4454+ policy : undefined ,
44494455 isReportArchived : false ,
44504456 chatReport : undefined ,
44514457 currentUserLogin : CURRENT_USER_EMAIL ,
@@ -4467,6 +4473,7 @@ describe('OptionsListUtils', () => {
44674473 translate : translateLocal ,
44684474 report,
44694475 lastActorDetails : null ,
4476+ policy : undefined ,
44704477 isReportArchived : false ,
44714478 chatReport : undefined ,
44724479 currentUserLogin : CURRENT_USER_EMAIL ,
@@ -4488,6 +4495,7 @@ describe('OptionsListUtils', () => {
44884495 translate : translateLocal ,
44894496 report,
44904497 lastActorDetails : null ,
4498+ policy : undefined ,
44914499 isReportArchived : false ,
44924500 chatReport : undefined ,
44934501 currentUserLogin : CURRENT_USER_EMAIL ,
@@ -4509,6 +4517,7 @@ describe('OptionsListUtils', () => {
45094517 translate : translateLocal ,
45104518 report,
45114519 lastActorDetails : null ,
4520+ policy : undefined ,
45124521 isReportArchived : false ,
45134522 chatReport : undefined ,
45144523 currentUserLogin : CURRENT_USER_EMAIL ,
@@ -4530,6 +4539,7 @@ describe('OptionsListUtils', () => {
45304539 translate : translateLocal ,
45314540 report,
45324541 lastActorDetails : null ,
4542+ policy : undefined ,
45334543 isReportArchived : false ,
45344544 chatReport : undefined ,
45354545 currentUserLogin : CURRENT_USER_EMAIL ,
@@ -4551,6 +4561,7 @@ describe('OptionsListUtils', () => {
45514561 translate : translateLocal ,
45524562 report,
45534563 lastActorDetails : null ,
4564+ policy : undefined ,
45544565 isReportArchived : false ,
45554566 chatReport : undefined ,
45564567 currentUserLogin : CURRENT_USER_EMAIL ,
@@ -4576,6 +4587,7 @@ describe('OptionsListUtils', () => {
45764587 translate : translateLocal ,
45774588 report,
45784589 lastActorDetails : null ,
4590+ policy : undefined ,
45794591 isReportArchived : false ,
45804592 chatReport : undefined ,
45814593 currentUserLogin : CURRENT_USER_EMAIL ,
@@ -4603,6 +4615,7 @@ describe('OptionsListUtils', () => {
46034615 translate : translateLocal ,
46044616 report,
46054617 lastActorDetails : null ,
4618+ policy : undefined ,
46064619 isReportArchived : false ,
46074620 chatReport : undefined ,
46084621 currentUserLogin : CURRENT_USER_EMAIL ,
@@ -4621,6 +4634,7 @@ describe('OptionsListUtils', () => {
46214634 translate : translateLocal ,
46224635 report,
46234636 lastActorDetails : null ,
4637+ policy : undefined ,
46244638 isReportArchived : false ,
46254639 chatReport : undefined ,
46264640 currentUserLogin : CURRENT_USER_EMAIL ,
@@ -4651,6 +4665,7 @@ describe('OptionsListUtils', () => {
46514665 translate : translateLocal ,
46524666 report,
46534667 lastActorDetails : null ,
4668+ policy : undefined ,
46544669 isReportArchived : false ,
46554670 chatReport : undefined ,
46564671 currentUserLogin : CURRENT_USER_EMAIL ,
@@ -4690,6 +4705,7 @@ describe('OptionsListUtils', () => {
46904705 report,
46914706 translate : translateLocal ,
46924707 lastActorDetails : null ,
4708+ policy : undefined ,
46934709 isReportArchived : false ,
46944710 chatReport : undefined ,
46954711 currentUserLogin : CURRENT_USER_EMAIL ,
@@ -4775,6 +4791,7 @@ describe('OptionsListUtils', () => {
47754791 translate : translateLocal ,
47764792 report,
47774793 lastActorDetails : null ,
4794+ policy : undefined ,
47784795 isReportArchived : false ,
47794796 chatReport : undefined ,
47804797 currentUserLogin : CURRENT_USER_EMAIL ,
@@ -4805,13 +4822,99 @@ describe('OptionsListUtils', () => {
48054822 translate : translateLocal ,
48064823 report,
48074824 lastActorDetails : null ,
4825+ policy : undefined ,
48084826 isReportArchived : false ,
48094827 chatReport : undefined ,
48104828 currentUserLogin : CURRENT_USER_EMAIL ,
48114829 } ) ;
48124830 expect ( lastMessage ) . toBe ( translate ( CONST . LOCALES . EN , 'iou.error.genericCreateFailureMessage' ) ) ;
48134831 } ) ;
48144832 } ) ;
4833+
4834+ describe ( 'archived report with policy' , ( ) => {
4835+ it ( 'should use the passed policy name for POLICY_DELETED archive reason' , async ( ) => {
4836+ const testPolicyID = 'archivePolicyTest' ;
4837+ const policy : Policy = {
4838+ id : testPolicyID ,
4839+ name : 'Test Workspace' ,
4840+ type : CONST . POLICY . TYPE . TEAM ,
4841+ } as Policy ;
4842+ const report : Report = {
4843+ ...createRandomReport ( 0 , undefined ) ,
4844+ policyID : testPolicyID ,
4845+ type : CONST . REPORT . TYPE . CHAT ,
4846+ } ;
4847+ const closedAction = {
4848+ ...createRandomReportAction ( 1 ) ,
4849+ actionName : CONST . REPORT . ACTIONS . TYPE . CLOSED ,
4850+ originalMessage : {
4851+ policyName : policy . name ,
4852+ reason : CONST . REPORT . ARCHIVE_REASON . POLICY_DELETED ,
4853+ } ,
4854+ } as ReportAction ;
4855+ await Onyx . merge ( `${ ONYXKEYS . COLLECTION . REPORT_ACTIONS } ${ report . reportID } ` , {
4856+ [ closedAction . reportActionID ] : closedAction ,
4857+ } ) ;
4858+
4859+ const lastMessage = getLastMessageTextForReport ( {
4860+ translate : translateLocal ,
4861+ report,
4862+ lastActorDetails : null ,
4863+ policy,
4864+ isReportArchived : true ,
4865+ chatReport : undefined ,
4866+ currentUserLogin : '' ,
4867+ } ) ;
4868+
4869+ expect ( lastMessage ) . toBe (
4870+ translateLocal ( 'reportArchiveReasons.policyDeleted' , {
4871+ policyName : policy . name ,
4872+ } ) ,
4873+ ) ;
4874+ } ) ;
4875+
4876+ it ( 'should use the passed policy name for REMOVED_FROM_POLICY archive reason' , async ( ) => {
4877+ const testPolicyID = 'archivePolicyTest2' ;
4878+ const policy : Policy = {
4879+ id : testPolicyID ,
4880+ name : 'My Workspace' ,
4881+ type : CONST . POLICY . TYPE . TEAM ,
4882+ } as Policy ;
4883+ const report : Report = {
4884+ ...createRandomReport ( 0 , undefined ) ,
4885+ policyID : testPolicyID ,
4886+ type : CONST . REPORT . TYPE . CHAT ,
4887+ } ;
4888+ const closedAction = {
4889+ ...createRandomReportAction ( 1 ) ,
4890+ actionName : CONST . REPORT . ACTIONS . TYPE . CLOSED ,
4891+ originalMessage : {
4892+ policyName : policy . name ,
4893+ reason : CONST . REPORT . ARCHIVE_REASON . REMOVED_FROM_POLICY ,
4894+ } ,
4895+ } as ReportAction ;
4896+ await Onyx . merge ( `${ ONYXKEYS . COLLECTION . REPORT_ACTIONS } ${ report . reportID } ` , {
4897+ [ closedAction . reportActionID ] : closedAction ,
4898+ } ) ;
4899+
4900+ const lastMessage = getLastMessageTextForReport ( {
4901+ translate : translateLocal ,
4902+ report,
4903+ lastActorDetails : null ,
4904+ policy,
4905+ isReportArchived : true ,
4906+ chatReport : undefined ,
4907+ currentUserLogin : '' ,
4908+ } ) ;
4909+
4910+ expect ( lastMessage ) . toBe (
4911+ translateLocal ( 'reportArchiveReasons.removedFromPolicy' , {
4912+ displayName : 'Hidden' ,
4913+ policyName : policy . name ,
4914+ } ) ,
4915+ ) ;
4916+ } ) ;
4917+ } ) ;
48154918 } ) ;
48164919
48174920 describe ( 'getPersonalDetailSearchTerms' , ( ) => {
@@ -6536,6 +6639,7 @@ describe('OptionsListUtils', () => {
65366639 translate : jest . fn ( ) . mockReturnValue ( '' ) ,
65376640 report,
65386641 lastActorDetails : null ,
6642+ policy : undefined ,
65396643 isReportArchived : false ,
65406644 chatReport,
65416645 currentUserLogin : CURRENT_USER_EMAIL ,
@@ -6555,6 +6659,7 @@ describe('OptionsListUtils', () => {
65556659 translate : jest . fn ( ) . mockReturnValue ( '' ) ,
65566660 report,
65576661 lastActorDetails : null ,
6662+ policy : undefined ,
65586663 isReportArchived : false ,
65596664 chatReport : undefined ,
65606665 currentUserLogin : CURRENT_USER_EMAIL ,
0 commit comments