@@ -12311,7 +12311,7 @@ describe('ReportUtils', () => {
1231112311 await Onyx.set(ONYXKEYS.SESSION, {email: currentUserEmail, accountID: currentUserAccountID});
1231212312 });
1231312313
12314- it("should navigate to the restricted action page if the active policy's billable actions are restricted", async () => {
12314+ it("should navigate to the restricted action page if the policy owner 's billable actions are restricted", async () => {
1231512315 // Given a transaction and an active policy where billable actions are restricted
1231612316 const transaction = createRandomTransaction(1);
1231712317 const activePolicy: Policy = {
@@ -12326,7 +12326,41 @@ describe('ReportUtils', () => {
1232612326 await Onyx.merge(ONYXKEYS.NVP_PRIVATE_OWNER_BILLING_GRACE_PERIOD_END, Math.floor(Date.now() / 1000) - 3600);
1232712327
1232812328 // When we call createDraftTransactionAndNavigateToParticipantSelector with the restricted policy
12329- createDraftTransactionAndNavigateToParticipantSelector(transaction.transactionID, '1', CONST.IOU.ACTION.CATEGORIZE, '1', undefined, undefined, activePolicy);
12329+ createDraftTransactionAndNavigateToParticipantSelector(transaction.transactionID, '1', CONST.IOU.ACTION.CATEGORIZE, '1', undefined, undefined, activePolicy, undefined);
12330+
12331+ // Then it should navigate to the restricted action page
12332+ expect(Navigation.navigate).toHaveBeenCalledWith(ROUTES.RESTRICTED_ACTION.getRoute(activePolicy.id));
12333+ });
12334+
12335+ it("should navigate to the restricted action page if the policy non-owner's billable actions are restricted", async () => {
12336+ // Given a transaction and an active policy where billable actions are restricted for non-owner
12337+ const transaction = createRandomTransaction(3);
12338+ const ownerAccountID = 123;
12339+ const activePolicy: Policy = {
12340+ ...createRandomPolicy(102),
12341+ ownerAccountID,
12342+ };
12343+
12344+ await Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION}${transaction.transactionID}`, transaction);
12345+ await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${1}`, {});
12346+ await Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${activePolicy.id}`, activePolicy);
12347+ const userBillingGraceEndPeriodCollection = {
12348+ [`${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_USER_BILLING_GRACE_PERIOD_END}${ownerAccountID}`]: {
12349+ value: 1,
12350+ },
12351+ };
12352+
12353+ // When we call createDraftTransactionAndNavigateToParticipantSelector
12354+ createDraftTransactionAndNavigateToParticipantSelector(
12355+ transaction.transactionID,
12356+ '1',
12357+ CONST.IOU.ACTION.CATEGORIZE,
12358+ '1',
12359+ undefined,
12360+ undefined,
12361+ activePolicy,
12362+ userBillingGraceEndPeriodCollection,
12363+ );
1233012364
1233112365 // Then it should navigate to the restricted action page
1233212366 expect(Navigation.navigate).toHaveBeenCalledWith(ROUTES.RESTRICTED_ACTION.getRoute(activePolicy.id));
@@ -12354,7 +12388,7 @@ describe('ReportUtils', () => {
1235412388 await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${policyExpenseReport.reportID}`, policyExpenseReport);
1235512389
1235612390 // When we call createDraftTransactionAndNavigateToParticipantSelector
12357- createDraftTransactionAndNavigateToParticipantSelector(transaction.transactionID, '1', CONST.IOU.ACTION.CATEGORIZE, '1', undefined, undefined, activePolicy);
12391+ createDraftTransactionAndNavigateToParticipantSelector(transaction.transactionID, '1', CONST.IOU.ACTION.CATEGORIZE, '1', undefined, undefined, activePolicy, undefined );
1235812392
1235912393 // Then it should navigate to the category step
1236012394 expect(Navigation.navigate).toHaveBeenCalledWith(
@@ -12384,7 +12418,7 @@ describe('ReportUtils', () => {
1238412418 await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${policyExpenseReport.reportID}`, policyExpenseReport);
1238512419
1238612420 // When we call createDraftTransactionAndNavigateToParticipantSelector with undefined activePolicy
12387- createDraftTransactionAndNavigateToParticipantSelector(transaction.transactionID, '2', CONST.IOU.ACTION.CATEGORIZE, '2', undefined, undefined, undefined);
12421+ createDraftTransactionAndNavigateToParticipantSelector(transaction.transactionID, '2', CONST.IOU.ACTION.CATEGORIZE, '2', undefined, undefined, undefined, undefined );
1238812422
1238912423 // Then it should automatically pick the available policy and navigate to the category step
1239012424 expect(Navigation.navigate).toHaveBeenCalledWith(
@@ -12401,7 +12435,7 @@ describe('ReportUtils', () => {
1240112435 await Onyx.setCollection(ONYXKEYS.COLLECTION.POLICY, {});
1240212436
1240312437 // When we call createDraftTransactionAndNavigateToParticipantSelector with undefined activePolicy
12404- createDraftTransactionAndNavigateToParticipantSelector(transaction.transactionID, '1', CONST.IOU.ACTION.CATEGORIZE, '1', undefined, undefined, undefined);
12438+ createDraftTransactionAndNavigateToParticipantSelector(transaction.transactionID, '1', CONST.IOU.ACTION.CATEGORIZE, '1', undefined, undefined, undefined, undefined );
1240512439
1240612440 // Then it should navigate to the upgrade page because no policies were found to categorize with
1240712441 expect(Navigation.navigate).toHaveBeenCalledWith(
@@ -12439,7 +12473,7 @@ describe('ReportUtils', () => {
1243912473 await Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${policy2.id}`, policy2);
1244012474
1244112475 // When we call createDraftTransactionAndNavigateToParticipantSelector with undefined activePolicy
12442- createDraftTransactionAndNavigateToParticipantSelector(transaction.transactionID, '1', CONST.IOU.ACTION.CATEGORIZE, '1', undefined, undefined, undefined);
12476+ createDraftTransactionAndNavigateToParticipantSelector(transaction.transactionID, '1', CONST.IOU.ACTION.CATEGORIZE, '1', undefined, undefined, undefined, undefined );
1244312477
1244412478 // Then it should navigate to the upgrade page because it's ambiguous which policy to use
1244512479 expect(Navigation.navigate).toHaveBeenCalledWith(
@@ -12473,7 +12507,7 @@ describe('ReportUtils', () => {
1247312507 await Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${activePolicy.id}`, activePolicy);
1247412508
1247512509 // When we call createDraftTransactionAndNavigateToParticipantSelector
12476- createDraftTransactionAndNavigateToParticipantSelector(transaction.transactionID, '1', CONST.IOU.ACTION.CATEGORIZE, '1', undefined, undefined, activePolicy);
12510+ createDraftTransactionAndNavigateToParticipantSelector(transaction.transactionID, '1', CONST.IOU.ACTION.CATEGORIZE, '1', undefined, undefined, activePolicy, undefined );
1247712511
1247812512 // Then it should log a warning and not navigate
1247912513 expect(logWarnSpy).toHaveBeenCalledWith('policyExpenseReportID is not valid during expense categorizing');
0 commit comments