@@ -1380,4 +1380,114 @@ describe('getSecondaryTransactionThreadActions', () => {
13801380 const result = getSecondaryReportActions ( { report, chatReport, reportTransactions : [ ] , violations : { } , policy, policies, reportActions} ) ;
13811381 expect ( result . includes ( CONST . REPORT . SECONDARY_ACTIONS . CHANGE_WORKSPACE ) ) . toBe ( false ) ;
13821382 } ) ;
1383+
1384+ it ( 'includes the SPLIT option if the current user belongs to the workspace' , async ( ) => {
1385+ const report = {
1386+ reportID : REPORT_ID ,
1387+ policyID : POLICY_ID ,
1388+ type : CONST . REPORT . TYPE . EXPENSE ,
1389+ ownerAccountID : EMPLOYEE_ACCOUNT_ID ,
1390+ managerID : EMPLOYEE_ACCOUNT_ID ,
1391+ stateNum : CONST . REPORT . STATE_NUM . SUBMITTED ,
1392+ statusNum : CONST . REPORT . STATUS_NUM . SUBMITTED ,
1393+ } as unknown as Report ;
1394+
1395+ const transaction = {
1396+ transactionID : 'TRANSACTION_ID' ,
1397+ status : CONST . TRANSACTION . STATUS . POSTED ,
1398+ amount : 10 ,
1399+ merchant : 'Merchant' ,
1400+ date : '2025-01-01' ,
1401+ } as unknown as Transaction ;
1402+
1403+ const policy = {
1404+ id : POLICY_ID ,
1405+ type : CONST . POLICY . TYPE . TEAM ,
1406+ isPolicyExpenseChatEnabled : true ,
1407+ employeeList : {
1408+ [ EMPLOYEE_EMAIL ] : { email : EMPLOYEE_EMAIL , role : CONST . POLICY . ROLE . USER } ,
1409+ [ ADMIN_EMAIL ] : { email : ADMIN_EMAIL , role : CONST . POLICY . ROLE . ADMIN } ,
1410+ } ,
1411+ role : CONST . POLICY . ROLE . ADMIN ,
1412+ } as unknown as Policy ;
1413+
1414+ await Onyx . merge ( `${ ONYXKEYS . COLLECTION . POLICY } ${ POLICY_ID } ` , policy ) ;
1415+ await Onyx . merge ( `${ ONYXKEYS . COLLECTION . REPORT } ${ REPORT_ID } ` , report ) ;
1416+
1417+ const result = getSecondaryTransactionThreadActions ( report , transaction , [ actionR14932 ] , policy ) ;
1418+ expect ( result . includes ( CONST . REPORT . SECONDARY_ACTIONS . SPLIT ) ) . toBe ( true ) ;
1419+ } ) ;
1420+
1421+ it ( 'does not include the SPLIT option if the current user belongs to the workspace' , async ( ) => {
1422+ const report = {
1423+ reportID : REPORT_ID ,
1424+ policyID : POLICY_ID ,
1425+ type : CONST . REPORT . TYPE . EXPENSE ,
1426+ ownerAccountID : EMPLOYEE_ACCOUNT_ID ,
1427+ managerID : EMPLOYEE_ACCOUNT_ID ,
1428+ stateNum : CONST . REPORT . STATE_NUM . SUBMITTED ,
1429+ statusNum : CONST . REPORT . STATUS_NUM . SUBMITTED ,
1430+ } as unknown as Report ;
1431+
1432+ const transaction = {
1433+ transactionID : 'TRANSACTION_ID' ,
1434+ status : CONST . TRANSACTION . STATUS . POSTED ,
1435+ amount : 10 ,
1436+ merchant : 'Merchant' ,
1437+ date : '2025-01-01' ,
1438+ } as unknown as Transaction ;
1439+
1440+ const policy = {
1441+ id : POLICY_ID ,
1442+ type : CONST . POLICY . TYPE . TEAM ,
1443+ isPolicyExpenseChatEnabled : true ,
1444+ employeeList : {
1445+ [ ADMIN_EMAIL ] : { email : ADMIN_EMAIL , role : CONST . POLICY . ROLE . ADMIN } ,
1446+ } ,
1447+ role : CONST . POLICY . ROLE . ADMIN ,
1448+ } as unknown as Policy ;
1449+
1450+ await Onyx . merge ( `${ ONYXKEYS . COLLECTION . POLICY } ${ POLICY_ID } ` , policy ) ;
1451+ await Onyx . merge ( `${ ONYXKEYS . COLLECTION . REPORT } ${ REPORT_ID } ` , report ) ;
1452+
1453+ const result = getSecondaryTransactionThreadActions ( report , transaction , [ actionR14932 ] , policy ) ;
1454+ expect ( result . includes ( CONST . REPORT . SECONDARY_ACTIONS . SPLIT ) ) . toBe ( false ) ;
1455+ } ) ;
1456+
1457+ it ( 'does not include the SPLIT option if the policy is not expense chat enabled' , async ( ) => {
1458+ const report = {
1459+ reportID : REPORT_ID ,
1460+ policyID : POLICY_ID ,
1461+ type : CONST . REPORT . TYPE . EXPENSE ,
1462+ ownerAccountID : EMPLOYEE_ACCOUNT_ID ,
1463+ managerID : EMPLOYEE_ACCOUNT_ID ,
1464+ stateNum : CONST . REPORT . STATE_NUM . SUBMITTED ,
1465+ statusNum : CONST . REPORT . STATUS_NUM . SUBMITTED ,
1466+ } as unknown as Report ;
1467+
1468+ const transaction = {
1469+ transactionID : 'TRANSACTION_ID' ,
1470+ status : CONST . TRANSACTION . STATUS . POSTED ,
1471+ amount : 10 ,
1472+ merchant : 'Merchant' ,
1473+ date : '2025-01-01' ,
1474+ } as unknown as Transaction ;
1475+
1476+ const policy = {
1477+ id : POLICY_ID ,
1478+ type : CONST . POLICY . TYPE . TEAM ,
1479+ isPolicyExpenseChatEnabled : false ,
1480+ employeeList : {
1481+ [ EMPLOYEE_EMAIL ] : { email : EMPLOYEE_EMAIL , role : CONST . POLICY . ROLE . USER } ,
1482+ [ ADMIN_EMAIL ] : { email : ADMIN_EMAIL , role : CONST . POLICY . ROLE . ADMIN } ,
1483+ } ,
1484+ role : CONST . POLICY . ROLE . ADMIN ,
1485+ } as unknown as Policy ;
1486+
1487+ await Onyx . merge ( `${ ONYXKEYS . COLLECTION . POLICY } ${ POLICY_ID } ` , policy ) ;
1488+ await Onyx . merge ( `${ ONYXKEYS . COLLECTION . REPORT } ${ REPORT_ID } ` , report ) ;
1489+
1490+ const result = getSecondaryTransactionThreadActions ( report , transaction , [ actionR14932 ] , policy ) ;
1491+ expect ( result . includes ( CONST . REPORT . SECONDARY_ACTIONS . SPLIT ) ) . toBe ( false ) ;
1492+ } ) ;
13831493} ) ;
0 commit comments