@@ -1760,6 +1760,77 @@ describe('actions/Report', () => {
17601760 } ) ;
17611761 } ) ;
17621762
1763+ describe ( 'changeReportPolicy' , ( ) => {
1764+ it ( 'should unarchive the expense report' , async ( ) => {
1765+ // Given an archived expense report
1766+ const expenseReport : OnyxTypes . Report = {
1767+ ...createRandomReport ( 1 ) ,
1768+ type : CONST . REPORT . TYPE . EXPENSE ,
1769+ policyID : '1' ,
1770+ } ;
1771+ await Onyx . merge ( `${ ONYXKEYS . COLLECTION . REPORT_NAME_VALUE_PAIRS } ${ expenseReport . reportID } ` , {
1772+ private_isArchived : DateUtils . getDBTime ( ) ,
1773+ } ) ;
1774+
1775+ // When moving to another workspace
1776+ Report . changeReportPolicy ( expenseReport , '2' ) ;
1777+ await waitForBatchedUpdates ( ) ;
1778+
1779+ // Then the expense report should not be archived anymore
1780+ const isArchived = await new Promise < boolean > ( ( resolve ) => {
1781+ const connection = Onyx . connect ( {
1782+ key : `${ ONYXKEYS . COLLECTION . REPORT_NAME_VALUE_PAIRS } ${ expenseReport . reportID } ` ,
1783+ callback : ( val ) => {
1784+ resolve ( ! ! val ?. private_isArchived ) ;
1785+ Onyx . disconnect ( connection ) ;
1786+ } ,
1787+ } ) ;
1788+ } ) ;
1789+ expect ( isArchived ) . toBe ( false ) ;
1790+ } ) ;
1791+ } ) ;
1792+
1793+ describe ( 'changeReportPolicyAndInviteSubmitter' , ( ) => {
1794+ it ( 'should unarchive the expense report' , async ( ) => {
1795+ // Given an archived expense report
1796+ const ownerAccountID = 1 ;
1797+ const ownerEmail = 'owner@gmail.com' ;
1798+ const adminEmail = 'admin@gmail.com' ;
1799+ const expenseReport : OnyxTypes . Report = {
1800+ ...createRandomReport ( 1 ) ,
1801+ type : CONST . REPORT . TYPE . EXPENSE ,
1802+ policyID : '1' ,
1803+ ownerAccountID,
1804+ } ;
1805+ await Onyx . merge ( `${ ONYXKEYS . COLLECTION . REPORT_NAME_VALUE_PAIRS } ${ expenseReport . reportID } ` , {
1806+ private_isArchived : DateUtils . getDBTime ( ) ,
1807+ } ) ;
1808+ await Onyx . merge ( ONYXKEYS . PERSONAL_DETAILS_LIST , {
1809+ [ ownerAccountID ] : {
1810+ login : ownerEmail ,
1811+ } ,
1812+ } ) ;
1813+
1814+ // When moving to another workspace
1815+ Report . changeReportPolicyAndInviteSubmitter ( expenseReport , '2' , {
1816+ [ adminEmail ] : { role : CONST . POLICY . ROLE . ADMIN } ,
1817+ } ) ;
1818+ await waitForBatchedUpdates ( ) ;
1819+
1820+ // Then the expense report should not be archived anymore
1821+ const isArchived = await new Promise < boolean > ( ( resolve ) => {
1822+ const connection = Onyx . connect ( {
1823+ key : `${ ONYXKEYS . COLLECTION . REPORT_NAME_VALUE_PAIRS } ${ expenseReport . reportID } ` ,
1824+ callback : ( val ) => {
1825+ resolve ( ! ! val ?. private_isArchived ) ;
1826+ Onyx . disconnect ( connection ) ;
1827+ } ,
1828+ } ) ;
1829+ } ) ;
1830+ expect ( isArchived ) . toBe ( false ) ;
1831+ } ) ;
1832+ } ) ;
1833+
17631834 describe ( 'buildOptimisticChangePolicyData' , ( ) => {
17641835 it ( 'should build the optimistic data next step for the change policy data' , ( ) => {
17651836 const report : OnyxTypes . Report = {
0 commit comments