Skip to content

Commit e1e5744

Browse files
dukenv0307claude
andcommitted
Address review: reorder cheap guards before policy scan, exclude pending-delete workspaces
- Move O(1) trial/billing/readiness guards ahead of the O(n) getOwnedPaidPolicies scan (PERF-2) - Exclude pending-delete policies so an offline/queued workspace deletion also hides the reminder Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent c6308b8 commit e1e5744

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/hooks/useTrialPaymentReminder.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Determines whether the trial payment reminder modal is eligible to show and which variant/countdown
33
* to display, based on the user's free-trial dates, payment-card status, and prior dismissals.
44
*/
5-
import {getOwnedPaidPolicies} from '@libs/PolicyUtils';
5+
import {getOwnedPaidPolicies, isPendingDeletePolicy} from '@libs/PolicyUtils';
66
import {calculateRemainingTrialSeconds, calculateTrialDayNumber, doesUserHavePaymentCardAdded, isUserOnFreeTrial} from '@libs/SubscriptionUtils';
77

88
import {setNameValuePair} from '@userActions/User';
@@ -225,9 +225,6 @@ function useTrialPaymentReminder() {
225225
if (!isUserOnFreeTrial(firstDayFreeTrial, lastDayFreeTrial)) {
226226
return false;
227227
}
228-
if (!getOwnedPaidPolicies(policies, currentUserAccountID).length) {
229-
return false;
230-
}
231228
if (isLoadingOnyxValue(billingFundIDResult)) {
232229
return false;
233230
}
@@ -237,6 +234,9 @@ function useTrialPaymentReminder() {
237234
if (readinessState !== READINESS_STATE.READY) {
238235
return false;
239236
}
237+
if (!getOwnedPaidPolicies(policies, currentUserAccountID).some((policy) => !isPendingDeletePolicy(policy))) {
238+
return false;
239+
}
240240
if (isLoadingOnyxValue(dismissedTimestampResult)) {
241241
return false;
242242
}

0 commit comments

Comments
 (0)