diff --git a/src/components/learner-credit-management/cards/tests/CourseCard.test.jsx b/src/components/learner-credit-management/cards/tests/CourseCard.test.jsx index 92641be830..7de35375f1 100644 --- a/src/components/learner-credit-management/cards/tests/CourseCard.test.jsx +++ b/src/components/learner-credit-management/cards/tests/CourseCard.test.jsx @@ -53,7 +53,7 @@ jest.mock('../../../../data/services/EnterpriseAccessApiService'); const futureStartDate = dayjs().add(5, 'days').toISOString(); const pastStartDate = dayjs().subtract(5, 'days').toISOString(); -const enrollByTimestamp = dayjs().subtract(10, 'days').unix(); +const enrollByTimestamp = dayjs().add(2, 'days').unix(); const enrollByDropdownText = `Enroll by ${dayjs.unix(enrollByTimestamp).format(SHORT_MONTH_DATE_FORMAT)}`; const originalData = { diff --git a/src/components/learner-credit-management/data/utils.js b/src/components/learner-credit-management/data/utils.js index 8a5c25f50b..7927f680d7 100644 --- a/src/components/learner-credit-management/data/utils.js +++ b/src/components/learner-credit-management/data/utils.js @@ -660,13 +660,16 @@ export const getAssignableCourseRuns = ({ courseRuns, subsidyExpirationDatetime, }) => { let isEligibleForEnrollment = true; if (hasEnrollBy) { - isEligibleForEnrollment = dayjs(enrollBy).isBefore( - minimumEnrollByDateFromToday({ subsidyExpirationDatetime }), + const enrollByDate = dayjs(enrollBy); + // Determine eligibility based on the provided enrollBy is and the subsidy expiration date - refund threshold + isEligibleForEnrollment = ( + !isDateBeforeToday(enrollByDate) + && enrollByDate.isBefore(minimumEnrollByDateFromToday({ subsidyExpirationDatetime })) ); // Late redemption filter if (isDateBeforeToday(enrollBy) && isLateRedemptionAllowed) { const lateEnrollmentCutoff = dayjs().subtract(LATE_ENROLLMENTS_BUFFER_DAYS, 'days'); - isEligibleForEnrollment = dayjs(enrollBy).isAfter(lateEnrollmentCutoff); + isEligibleForEnrollment = enrollByDate.isAfter(lateEnrollmentCutoff); return isLateEnrollmentEligible && isEligibleForEnrollment; } }