@@ -1230,6 +1230,179 @@ describe('PolicyUtils', () => {
12301230 const result2 = getPolicyBrickRoadIndicatorStatus ( policyWithoutConnectionFailures , false ) ;
12311231 expect ( result2 ) . toBeUndefined ( ) ;
12321232 } ) ;
1233+
1234+ describe ( 'QBO Export Errors' , ( ) => {
1235+ it ( 'does return an ERROR RBR when a QBO sync error exists for an admin' , ( ) => {
1236+ const policyWithQBOSyncError = {
1237+ ...baseAdminPolicy ,
1238+ connections : {
1239+ [ CONST . POLICY . CONNECTIONS . NAME . QBO ] : {
1240+ verified : false ,
1241+ lastSync : {
1242+ errorDate : new Date ( ) . toISOString ( ) ,
1243+ errorMessage : 'QBO sync failed' ,
1244+ isAuthenticationError : true ,
1245+ isConnected : false ,
1246+ isSuccessful : false ,
1247+ source : 'NEWEXPENSIFY' ,
1248+ successfulDate : '' ,
1249+ } ,
1250+ } ,
1251+ } as Connections ,
1252+ } as OnyxEntry < Policy > ;
1253+
1254+ const result = getPolicyBrickRoadIndicatorStatus ( policyWithQBOSyncError , false ) ;
1255+ expect ( result ) . toEqual ( CONST . BRICK_ROAD_INDICATOR_STATUS . ERROR ) ;
1256+ } ) ;
1257+
1258+ it ( 'does not return an ERROR RBR when a QBO sync error exists for a user' , ( ) => {
1259+ const policyWithQBOSyncError = {
1260+ ...baseUserPolicy ,
1261+ connections : {
1262+ [ CONST . POLICY . CONNECTIONS . NAME . QBO ] : {
1263+ verified : false ,
1264+ lastSync : {
1265+ errorDate : new Date ( ) . toISOString ( ) ,
1266+ errorMessage : 'QBO sync failed' ,
1267+ isAuthenticationError : true ,
1268+ isConnected : false ,
1269+ isSuccessful : false ,
1270+ source : 'NEWEXPENSIFY' ,
1271+ successfulDate : '' ,
1272+ } ,
1273+ } ,
1274+ } as Connections ,
1275+ } as OnyxEntry < Policy > ;
1276+
1277+ const result = getPolicyBrickRoadIndicatorStatus ( policyWithQBOSyncError , false ) ;
1278+ expect ( result ) . toBeUndefined ( ) ;
1279+ } ) ;
1280+
1281+ it ( 'does not return an ERROR RBR when no QBO sync errors exist for an admin' , ( ) => {
1282+ const policyWithSuccessfulQBOSync = {
1283+ ...baseAdminPolicy ,
1284+ connections : {
1285+ [ CONST . POLICY . CONNECTIONS . NAME . QBO ] : {
1286+ verified : true ,
1287+ lastSync : {
1288+ errorDate : '' ,
1289+ errorMessage : '' ,
1290+ isAuthenticationError : false ,
1291+ isConnected : true ,
1292+ isSuccessful : true ,
1293+ source : 'NEWEXPENSIFY' ,
1294+ successfulDate : new Date ( ) . toISOString ( ) ,
1295+ } ,
1296+ } ,
1297+ } as Connections ,
1298+ } as OnyxEntry < Policy > ;
1299+
1300+ const result = getPolicyBrickRoadIndicatorStatus ( policyWithSuccessfulQBOSync , false ) ;
1301+ expect ( result ) . toBeUndefined ( ) ;
1302+ } ) ;
1303+
1304+ it ( 'does not return an ERROR RBR when QBO sync is in progress for an admin' , ( ) => {
1305+ const policyWithQBOSyncError = {
1306+ ...baseAdminPolicy ,
1307+ connections : {
1308+ [ CONST . POLICY . CONNECTIONS . NAME . QBO ] : {
1309+ verified : false ,
1310+ lastSync : {
1311+ errorDate : new Date ( ) . toISOString ( ) ,
1312+ errorMessage : 'QBO sync failed' ,
1313+ isAuthenticationError : true ,
1314+ isConnected : false ,
1315+ isSuccessful : false ,
1316+ source : 'NEWEXPENSIFY' ,
1317+ successfulDate : '' ,
1318+ } ,
1319+ } ,
1320+ } as Connections ,
1321+ } as OnyxEntry < Policy > ;
1322+
1323+ // When sync is in progress (second parameter is true), should not show error
1324+ const result = getPolicyBrickRoadIndicatorStatus ( policyWithQBOSyncError , true ) ;
1325+ expect ( result ) . toBeUndefined ( ) ;
1326+ } ) ;
1327+
1328+ it ( 'does return an ERROR RBR when QBO reimbursable export destination account is missing for an admin' , ( ) => {
1329+ const policyWithMissingQBOAccount = {
1330+ ...baseAdminPolicy ,
1331+ connections : {
1332+ [ CONST . POLICY . CONNECTIONS . NAME . QBO ] : {
1333+ config : {
1334+ reimbursableExpensesExportDestination : CONST . QUICKBOOKS_REIMBURSABLE_ACCOUNT_TYPE . VENDOR_BILL ,
1335+ reimbursableExpensesAccount : undefined ,
1336+ } ,
1337+ } ,
1338+ } as Connections ,
1339+ } as OnyxEntry < Policy > ;
1340+
1341+ const result = getPolicyBrickRoadIndicatorStatus ( policyWithMissingQBOAccount , false ) ;
1342+ expect ( result ) . toEqual ( CONST . BRICK_ROAD_INDICATOR_STATUS . ERROR ) ;
1343+ } ) ;
1344+
1345+ it ( 'does not return an ERROR RBR when QBO reimbursable export destination account is missing for a user' , ( ) => {
1346+ const policyWithMissingQBOAccount = {
1347+ ...baseUserPolicy ,
1348+ connections : {
1349+ [ CONST . POLICY . CONNECTIONS . NAME . QBO ] : {
1350+ config : {
1351+ reimbursableExpensesExportDestination : CONST . QUICKBOOKS_REIMBURSABLE_ACCOUNT_TYPE . VENDOR_BILL ,
1352+ reimbursableExpensesAccount : undefined ,
1353+ } ,
1354+ } ,
1355+ } as Connections ,
1356+ } as OnyxEntry < Policy > ;
1357+
1358+ const result = getPolicyBrickRoadIndicatorStatus ( policyWithMissingQBOAccount , false ) ;
1359+ expect ( result ) . toBeUndefined ( ) ;
1360+ } ) ;
1361+
1362+ it ( 'does not return an ERROR RBR when QBO reimbursable export destination account is configured for an admin' , ( ) => {
1363+ const policyWithQBOConfigured = {
1364+ ...baseAdminPolicy ,
1365+ connections : {
1366+ [ CONST . POLICY . CONNECTIONS . NAME . QBO ] : {
1367+ config : {
1368+ reimbursableExpensesExportDestination : CONST . QUICKBOOKS_REIMBURSABLE_ACCOUNT_TYPE . VENDOR_BILL ,
1369+ reimbursableExpensesAccount : { id : '123' , name : 'Test Account' } ,
1370+ } ,
1371+ } ,
1372+ } as Connections ,
1373+ } as OnyxEntry < Policy > ;
1374+
1375+ const result = getPolicyBrickRoadIndicatorStatus ( policyWithQBOConfigured , false ) ;
1376+ expect ( result ) . toBeUndefined ( ) ;
1377+ } ) ;
1378+
1379+ it ( 'does not return an ERROR RBR when QBO connection does not exist for an admin' , ( ) => {
1380+ const policyWithoutQBOConnection = {
1381+ ...baseAdminPolicy ,
1382+ connections : { } ,
1383+ } as OnyxEntry < Policy > ;
1384+
1385+ const result = getPolicyBrickRoadIndicatorStatus ( policyWithoutQBOConnection , false ) ;
1386+ expect ( result ) . toBeUndefined ( ) ;
1387+ } ) ;
1388+
1389+ it ( 'does not return an ERROR RBR when QBO reimbursable export destination is not set for an admin' , ( ) => {
1390+ const policyWithQBONoExportDestination = {
1391+ ...baseAdminPolicy ,
1392+ connections : {
1393+ [ CONST . POLICY . CONNECTIONS . NAME . QBO ] : {
1394+ config : {
1395+ reimbursableExpensesExportDestination : undefined ,
1396+ reimbursableExpensesAccount : undefined ,
1397+ } ,
1398+ } ,
1399+ } as Connections ,
1400+ } as OnyxEntry < Policy > ;
1401+
1402+ const result = getPolicyBrickRoadIndicatorStatus ( policyWithQBONoExportDestination , false ) ;
1403+ expect ( result ) . toBeUndefined ( ) ;
1404+ } ) ;
1405+ } ) ;
12331406 } ) ;
12341407
12351408 describe ( 'hasDynamicExternalWorkflow' , ( ) => {
0 commit comments