@@ -18,7 +18,7 @@ import type {ReportCollectionDataSet} from '@src/types/onyx/Report';
1818import type { OnyxData } from '@src/types/onyx/Request' ;
1919import type { UpdateMoneyRequestDataKeys } from '../../src/libs/actions/IOU/UpdateMoneyRequest' ;
2020import * as TransactionUtils from '../../src/libs/TransactionUtils' ;
21- import type { PersonalDetails , PolicyTagLists , RecentWaypoint , Report , ReportAction , ReportActions , Transaction } from '../../src/types/onyx' ;
21+ import type { PersonalDetails , Policy , PolicyTagLists , RecentWaypoint , Report , ReportAction , ReportActions , Transaction } from '../../src/types/onyx' ;
2222import createRandomPolicy from '../utils/collections/policies' ;
2323import createRandomPolicyCategories from '../utils/collections/policyCategory' ;
2424import { createExpenseReport , createRandomReport } from '../utils/collections/reports' ;
@@ -1336,6 +1336,50 @@ describe('Transaction', () => {
13361336 expect ( missingTagViolations . some ( ( violation ) => violation . data ?. tagName === 'City' ) ) . toBe ( true ) ;
13371337 } ) ;
13381338
1339+ it ( 'removes AUTO_REPORTED_REJECTED_EXPENSE from transaction violations when moving to a paid group policy' , async ( ) => {
1340+ const policyID = '1001' ;
1341+ const transaction = generateTransaction ( { reportID : FAKE_OLD_REPORT_ID } ) ;
1342+ const oldIOUAction = createIOUAction ( transaction ) ;
1343+ const newExpenseReport = {
1344+ ...createExpenseReport ( Number ( FAKE_NEW_REPORT_ID ) ) ,
1345+ policyID,
1346+ stateNum : CONST . REPORT . STATE_NUM . OPEN ,
1347+ statusNum : CONST . REPORT . STATUS_NUM . OPEN ,
1348+ ownerAccountID : CURRENT_USER_ID ,
1349+ } ;
1350+ const policy : Policy = {
1351+ ...createRandomPolicy ( Number ( policyID ) , CONST . POLICY . TYPE . TEAM ) ,
1352+ requiresTag : false ,
1353+ requiresCategory : false ,
1354+ } ;
1355+
1356+ await Onyx . merge ( `${ ONYXKEYS . COLLECTION . TRANSACTION } ${ transaction . transactionID } ` , transaction ) ;
1357+ await Onyx . merge ( `${ ONYXKEYS . COLLECTION . REPORT_ACTIONS } ${ FAKE_OLD_REPORT_ID } ` , { [ oldIOUAction . reportActionID ] : oldIOUAction } ) ;
1358+ await Onyx . merge ( `${ ONYXKEYS . COLLECTION . TRANSACTION_VIOLATIONS } ${ transaction . transactionID } ` , [
1359+ { name : CONST . VIOLATIONS . AUTO_REPORTED_REJECTED_EXPENSE , type : CONST . VIOLATION_TYPES . VIOLATION , showInReview : true } ,
1360+ ] ) ;
1361+ await waitForBatchedUpdates ( ) ;
1362+
1363+ const allTransactions = {
1364+ [ `${ ONYXKEYS . COLLECTION . TRANSACTION } ${ transaction . transactionID } ` ] : transaction ,
1365+ } ;
1366+
1367+ changeTransactionsReport ( {
1368+ transactionIDs : [ transaction . transactionID ] ,
1369+ isASAPSubmitBetaEnabled : false ,
1370+ accountID : CURRENT_USER_ID ,
1371+ email : 'test@example.com' ,
1372+ newReport : newExpenseReport ,
1373+ policy,
1374+ allTransactions,
1375+ policyTagList : { } ,
1376+ } ) ;
1377+ await waitForBatchedUpdates ( ) ;
1378+
1379+ const updatedViolations = await getOnyxValue ( `${ ONYXKEYS . COLLECTION . TRANSACTION_VIOLATIONS } ${ transaction . transactionID } ` ) ;
1380+ expect ( updatedViolations ?. some ( ( violation ) => violation . name === CONST . VIOLATIONS . AUTO_REPORTED_REJECTED_EXPENSE ) ) . toBe ( false ) ;
1381+ } ) ;
1382+
13391383 it ( 'should auto-select a valid distance rate when moving a distance expense with an invalid P2P rate to a workspace' , async ( ) => {
13401384 const policyID = '100' ;
13411385 const validRateID = 'valid_rate_1' ;
0 commit comments