@@ -2,11 +2,10 @@ import { SubscriptionPlanId } from '../../constants.subscription';
2
2
import type { Organization } from './account/organization' ;
3
3
import type { Subscription } from './account/subscription' ;
4
4
import {
5
- computeSubscriptionState ,
6
5
getSubscriptionPlan ,
7
6
getSubscriptionPlanPriority ,
7
+ isSubscriptionExpired ,
8
8
SubscriptionPlanId ,
9
- SubscriptionState ,
10
9
} from './account/subscription' ;
11
10
12
11
export type GKLicenses = Partial < Record < GKLicenseType , GKLicense > > ;
@@ -75,7 +74,6 @@ export function getSubscriptionFromCheckIn(
75
74
76
75
let effectiveLicenses = Object . entries ( data . licenses . effectiveLicenses ) as [ GKLicenseType , GKLicense ] [ ] ;
77
76
let paidLicenses = Object . entries ( data . licenses . paidLicenses ) as [ GKLicenseType , GKLicense ] [ ] ;
78
- paidLicenses = paidLicenses . filter ( license => license [ 1 ] . latestStatus !== 'cancelled' ) ;
79
77
if ( paidLicenses . length > 1 ) {
80
78
paidLicenses . sort (
81
79
( a , b ) =>
@@ -85,6 +83,7 @@ export function getSubscriptionFromCheckIn(
85
83
licenseStatusPriority ( a [ 1 ] . latestStatus ) ) ,
86
84
) ;
87
85
}
86
+
88
87
if ( effectiveLicenses . length > 1 ) {
89
88
effectiveLicenses . sort (
90
89
( a , b ) =>
@@ -183,17 +182,10 @@ export function getSubscriptionFromCheckIn(
183
182
) ;
184
183
}
185
184
186
- const isActualLicenseExpired =
187
- computeSubscriptionState ( {
188
- plan : {
189
- actual : actual ,
190
- effective : actual ,
191
- } ,
192
- account : account ,
193
- } ) === SubscriptionState . PaidExpired ;
194
185
if (
195
186
effective == null ||
196
- ( getSubscriptionPlanPriority ( actual . id ) >= getSubscriptionPlanPriority ( effective . id ) && ! isActualLicenseExpired )
187
+ ( getSubscriptionPlanPriority ( actual . id ) >= getSubscriptionPlanPriority ( effective . id ) &&
188
+ ! isSubscriptionExpired ( actual ) )
197
189
) {
198
190
effective = { ...actual } ;
199
191
}
0 commit comments