@@ -2,11 +2,10 @@ import { SubscriptionPlanId } from '../../constants.subscription';
22import type { Organization } from './account/organization' ;
33import type { Subscription } from './account/subscription' ;
44import {
5- computeSubscriptionState ,
65 getSubscriptionPlan ,
76 getSubscriptionPlanPriority ,
7+ isSubscriptionExpired ,
88 SubscriptionPlanId ,
9- SubscriptionState ,
109} from './account/subscription' ;
1110
1211export interface GKCheckInResponse {
@@ -73,7 +72,6 @@ export function getSubscriptionFromCheckIn(
7372
7473 let effectiveLicenses = Object . entries ( data . licenses . effectiveLicenses ) as [ GKLicenseType , GKLicense ] [ ] ;
7574 let paidLicenses = Object . entries ( data . licenses . paidLicenses ) as [ GKLicenseType , GKLicense ] [ ] ;
76- paidLicenses = paidLicenses . filter ( license => license [ 1 ] . latestStatus !== 'cancelled' ) ;
7775 if ( paidLicenses . length > 1 ) {
7876 paidLicenses . sort (
7977 ( a , b ) =>
@@ -83,6 +81,7 @@ export function getSubscriptionFromCheckIn(
8381 licenseStatusPriority ( a [ 1 ] . latestStatus ) ) ,
8482 ) ;
8583 }
84+
8685 if ( effectiveLicenses . length > 1 ) {
8786 effectiveLicenses . sort (
8887 ( a , b ) =>
@@ -181,17 +180,10 @@ export function getSubscriptionFromCheckIn(
181180 ) ;
182181 }
183182
184- const isActualLicenseExpired =
185- computeSubscriptionState ( {
186- plan : {
187- actual : actual ,
188- effective : actual ,
189- } ,
190- account : account ,
191- } ) === SubscriptionState . PaidExpired ;
192183 if (
193184 effective == null ||
194- ( getSubscriptionPlanPriority ( actual . id ) >= getSubscriptionPlanPriority ( effective . id ) && ! isActualLicenseExpired )
185+ ( getSubscriptionPlanPriority ( actual . id ) >= getSubscriptionPlanPriority ( effective . id ) &&
186+ ! isSubscriptionExpired ( actual ) )
195187 ) {
196188 effective = { ...actual } ;
197189 }
0 commit comments