Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New report param hasReceivedFreeTrialEndMessage check #45723

Merged
merged 11 commits into from
Jul 19, 2024
4 changes: 0 additions & 4 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
import * as ReportActionsUtils from './ReportActionsUtils';
import * as ReportConnection from './ReportConnection';
import StringUtils from './StringUtils';
import * as SubscriptionUtils from './SubscriptionUtils';

Check failure on line 80 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

'SubscriptionUtils' is defined but never used
import * as TransactionUtils from './TransactionUtils';
import * as Url from './Url';
import type {AvatarSource} from './UserUtils';
Expand Down Expand Up @@ -2381,10 +2381,6 @@
return true;
}

if (isChatUsedForOnboarding(optionOrReport) && SubscriptionUtils.hasUserFreeTrialEnded() && !SubscriptionUtils.doesUserHavePaymentCardAdded()) {
return true;
}

return false;
}

Expand Down
42 changes: 0 additions & 42 deletions tests/unit/ReportUtilsTest.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/naming-convention */
import {addDays, format as formatDate, subDays} from 'date-fns';

Check failure on line 2 in tests/unit/ReportUtilsTest.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

'subDays' is defined but never used
import type {OnyxEntry} from 'react-native-onyx';
import Onyx from 'react-native-onyx';
import DateUtils from '@libs/DateUtils';
Expand Down Expand Up @@ -387,48 +387,6 @@

expect(ReportUtils.requiresAttentionFromCurrentUser(report)).toBe(false);
});

it('returns false if the user free trial has ended and it added a payment card', async () => {
await Onyx.multiSet({
[ONYXKEYS.NVP_LAST_DAY_FREE_TRIAL]: formatDate(addDays(new Date(), 1), CONST.DATE.FNS_DATE_TIME_FORMAT_STRING), // trial not ended
[ONYXKEYS.NVP_BILLING_FUND_ID]: 8010, // payment card added
});

const report: Report = {
...LHNTestUtils.getFakeReport(),
chatType: CONST.REPORT.CHAT_TYPE.SYSTEM,
};

expect(ReportUtils.requiresAttentionFromCurrentUser(report)).toBe(false);
});

it("returns true if the report is the system chat, the user free trial has ended and it didn't add a payment card yet", async () => {
await Onyx.multiSet({
[ONYXKEYS.NVP_LAST_DAY_FREE_TRIAL]: formatDate(subDays(new Date(), 1), CONST.DATE.FNS_DATE_TIME_FORMAT_STRING), // trial ended
[ONYXKEYS.NVP_BILLING_FUND_ID]: null, // no payment card added
});

const report: Report = {
...LHNTestUtils.getFakeReport(),
chatType: CONST.REPORT.CHAT_TYPE.SYSTEM,
};

expect(ReportUtils.requiresAttentionFromCurrentUser(report)).toBe(true);
});

it("returns true if the report is the concierge chat, the user free trial has ended and it didn't add a payment card yet", async () => {
await Onyx.multiSet({
[ONYXKEYS.NVP_LAST_DAY_FREE_TRIAL]: formatDate(subDays(new Date(), 1), CONST.DATE.FNS_DATE_TIME_FORMAT_STRING), // trial ended
[ONYXKEYS.NVP_BILLING_FUND_ID]: null, // no payment card added
[ONYXKEYS.SESSION]: {email: currentUserEmail, accountID: 8}, // even account id
});

const report: Report = {
...LHNTestUtils.getFakeReport([CONST.ACCOUNT_ID.CONCIERGE]),
};

expect(ReportUtils.requiresAttentionFromCurrentUser(report)).toBe(true);
});
});

describe('getMoneyRequestOptions', () => {
Expand Down
Loading