fix: sort licenses by whether they are current in ascending order before further processing #1154
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Bug 🐛
(ENT-9373)
tl;dr; Some subscription licenses are getting treated as expired in the UX, even though they have activated license in a current subscription plan:
Learners who have an activated subscription license at the time a subscription plan renewal was processed (i.e., where their activated license is copied to the renewal plan), end up incorrectly seeing their activated license as expired for the current subscription plan.
In this case of a processed renewal for a learner who had an activated license, the
learner-licenses
API begins returning the activated renewal license first in the list of licenses tied to the authenticated learner. As a result, thefetchSubscriptions
logic which parses the list of subscription licenses ends up extracting the first activated subscription license returned by the API, aka the activated renewal license, not the current license.Given this, because the determined subscription license to use throughout the UX ends up being the renewal license, the plan's
isCurrent
flag is false, triggering the expiration experience.Resolution 💪
Sort the returned list of subscription licenses from the
learner-licenses
API to prioritize the current licenses when grouping licenses by status. By doing so, we will ensure the extracted license fromfetchSubscriptions
will be a current license, if one exists.Alternative approaches to consider
learner-licenses
to exclude upcoming subscription plans. We currently passcurrent_plans_only: false
to ensure we include expired plans to support the expiration UX, but this pulls in upcoming/scheduled plans as a result.learner-licenses
to order the response list of licenses by whether the associated subscription planisCurrent
.For all changes
Only if submitting a visual change