@@ -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 interface GKCheckInResponse {
@@ -73,7 +72,6 @@ export function getSubscriptionFromCheckIn(
73
72
74
73
let effectiveLicenses = Object . entries ( data . licenses . effectiveLicenses ) as [ GKLicenseType , GKLicense ] [ ] ;
75
74
let paidLicenses = Object . entries ( data . licenses . paidLicenses ) as [ GKLicenseType , GKLicense ] [ ] ;
76
- paidLicenses = paidLicenses . filter ( license => license [ 1 ] . latestStatus !== 'cancelled' ) ;
77
75
if ( paidLicenses . length > 1 ) {
78
76
paidLicenses . sort (
79
77
( a , b ) =>
@@ -83,6 +81,7 @@ export function getSubscriptionFromCheckIn(
83
81
licenseStatusPriority ( a [ 1 ] . latestStatus ) ) ,
84
82
) ;
85
83
}
84
+
86
85
if ( effectiveLicenses . length > 1 ) {
87
86
effectiveLicenses . sort (
88
87
( a , b ) =>
@@ -181,17 +180,10 @@ export function getSubscriptionFromCheckIn(
181
180
) ;
182
181
}
183
182
184
- const isActualLicenseExpired =
185
- computeSubscriptionState ( {
186
- plan : {
187
- actual : actual ,
188
- effective : actual ,
189
- } ,
190
- account : account ,
191
- } ) === SubscriptionState . PaidExpired ;
192
183
if (
193
184
effective == null ||
194
- ( getSubscriptionPlanPriority ( actual . id ) >= getSubscriptionPlanPriority ( effective . id ) && ! isActualLicenseExpired )
185
+ ( getSubscriptionPlanPriority ( actual . id ) >= getSubscriptionPlanPriority ( effective . id ) &&
186
+ ! isSubscriptionExpired ( actual ) )
195
187
) {
196
188
effective = { ...actual } ;
197
189
}
0 commit comments