diff --git a/src/components/course/data/tests/utils.test.jsx b/src/components/course/data/tests/utils.test.jsx index 5aa174264a..a224b55133 100644 --- a/src/components/course/data/tests/utils.test.jsx +++ b/src/components/course/data/tests/utils.test.jsx @@ -692,7 +692,6 @@ describe('getSubscriptionDisabledEnrollmentReasonType', () => { }, ], }; - const reasonType = getSubscriptionDisabledEnrollmentReasonType({ customerAgreementConfig, catalogsWithCourse, diff --git a/src/components/course/data/utils.jsx b/src/components/course/data/utils.jsx index f6b782e4f4..c199c23ac2 100644 --- a/src/components/course/data/utils.jsx +++ b/src/components/course/data/utils.jsx @@ -679,12 +679,14 @@ export const getSubscriptionDisabledEnrollmentReasonType = ({ const subscriptionsApplicableToCourse = customerAgreementConfig?.subscriptions?.filter( subscription => catalogsWithCourse.includes(subscription?.enterpriseCatalogUuid), ); - const hasExpiredSubscriptions = subscriptionsApplicableToCourse?.filter( + const hasApplicableSubscriptions = subscriptionsApplicableToCourse.length > 0; + + const hasExpiredSubscriptions = hasApplicableSubscriptions && subscriptionsApplicableToCourse.every( subscription => subscription.daysUntilExpirationIncludingRenewals < 0, - )?.length > 0; - const hasExhaustedSubscriptions = subscriptionsApplicableToCourse?.filter( + ); + const hasExhaustedSubscriptions = hasApplicableSubscriptions && subscriptionsApplicableToCourse.every( subscription => subscription?.licenses?.unassigned === 0, - )?.length > 0; + ); const applicableSubscriptionNonExpiredNonExhausted = subscriptionsApplicableToCourse?.find( subscription => subscription.daysUntilExpirationIncludingRenewals >= 0 && subscription?.licenses?.unassigned > 0, );