-
Notifications
You must be signed in to change notification settings - Fork 3.6k
#6 - Get the billing grace end period collection with useOnyx #83149
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -801,7 +801,7 @@ | |
| }; | ||
|
|
||
| let allPersonalDetails: OnyxTypes.PersonalDetailsList = {}; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.PERSONAL_DETAILS_LIST, | ||
| callback: (value) => { | ||
| allPersonalDetails = value ?? {}; | ||
|
|
@@ -886,6 +886,7 @@ | |
| introSelected: OnyxEntry<OnyxTypes.IntroSelected>; | ||
| iouReportCurrentNextStepDeprecated: OnyxEntry<OnyxTypes.ReportNextStepDeprecated>; | ||
| currentUserAccountID: number; | ||
| userBillingGraceEndPeriodCollection: OnyxCollection<OnyxTypes.BillingGraceEndPeriod>; | ||
| paymentPolicyID?: string; | ||
| full?: boolean; | ||
| activePolicy?: OnyxEntry<OnyxTypes.Policy>; | ||
|
|
@@ -894,7 +895,7 @@ | |
| }; | ||
|
|
||
| let allTransactions: NonNullable<OnyxCollection<OnyxTypes.Transaction>> = {}; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.COLLECTION.TRANSACTION, | ||
| waitForCollectionCallback: true, | ||
| callback: (value) => { | ||
|
|
@@ -908,7 +909,7 @@ | |
| }); | ||
|
|
||
| let allTransactionDrafts: NonNullable<OnyxCollection<OnyxTypes.Transaction>> = {}; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.COLLECTION.TRANSACTION_DRAFT, | ||
| waitForCollectionCallback: true, | ||
| callback: (value) => { | ||
|
|
@@ -917,7 +918,7 @@ | |
| }); | ||
|
|
||
| let allTransactionViolations: NonNullable<OnyxCollection<OnyxTypes.TransactionViolations>> = {}; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS, | ||
| waitForCollectionCallback: true, | ||
| callback: (value) => { | ||
|
|
@@ -931,7 +932,7 @@ | |
| }); | ||
|
|
||
| let allPolicyTags: OnyxCollection<OnyxTypes.PolicyTagLists> = {}; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.COLLECTION.POLICY_TAGS, | ||
| waitForCollectionCallback: true, | ||
| callback: (value) => { | ||
|
|
@@ -944,7 +945,7 @@ | |
| }); | ||
|
|
||
| let allReports: OnyxCollection<OnyxTypes.Report>; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.COLLECTION.REPORT, | ||
| waitForCollectionCallback: true, | ||
| callback: (value) => { | ||
|
|
@@ -953,7 +954,7 @@ | |
| }); | ||
|
|
||
| let allReportNameValuePairs: OnyxCollection<OnyxTypes.ReportNameValuePairs>; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS, | ||
| waitForCollectionCallback: true, | ||
| callback: (value) => { | ||
|
|
@@ -963,7 +964,7 @@ | |
|
|
||
| let userAccountID = -1; | ||
| let currentUserEmail = ''; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.SESSION, | ||
| callback: (value) => { | ||
| currentUserEmail = value?.email ?? ''; | ||
|
|
@@ -972,7 +973,7 @@ | |
| }); | ||
|
|
||
| let deprecatedCurrentUserPersonalDetails: OnyxEntry<OnyxTypes.PersonalDetails>; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.PERSONAL_DETAILS_LIST, | ||
| callback: (value) => { | ||
| deprecatedCurrentUserPersonalDetails = value?.[userAccountID] ?? undefined; | ||
|
|
@@ -980,7 +981,7 @@ | |
| }); | ||
|
|
||
| let allReportActions: OnyxCollection<OnyxTypes.ReportActions>; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.COLLECTION.REPORT_ACTIONS, | ||
| waitForCollectionCallback: true, | ||
| callback: (actions) => { | ||
|
|
@@ -10527,13 +10528,14 @@ | |
| isASAPSubmitBetaEnabled: boolean, | ||
| expenseReportCurrentNextStepDeprecated: OnyxEntry<OnyxTypes.ReportNextStepDeprecated>, | ||
| betas: OnyxEntry<OnyxTypes.Beta[]>, | ||
| userBillingGraceEndPeriodCollection: OnyxCollection<OnyxTypes.BillingGraceEndPeriod>, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Adding Useful? React with 👍 / 👎. |
||
| full?: boolean, | ||
| ) { | ||
| if (!expenseReport) { | ||
| return; | ||
| } | ||
|
|
||
| if (expenseReport.policyID && shouldRestrictUserBillableActions(expenseReport.policyID)) { | ||
| if (expenseReport.policyID && shouldRestrictUserBillableActions(expenseReport.policyID, userBillingGraceEndPeriodCollection)) { | ||
| Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(expenseReport.policyID)); | ||
| return; | ||
| } | ||
|
|
@@ -11413,11 +11415,12 @@ | |
| hasViolations: boolean, | ||
| isASAPSubmitBetaEnabled: boolean, | ||
| expenseReportCurrentNextStepDeprecated: OnyxEntry<OnyxTypes.ReportNextStepDeprecated>, | ||
| userBillingGraceEndPeriodCollection: OnyxCollection<OnyxTypes.BillingGraceEndPeriod>, | ||
| ) { | ||
| if (!expenseReport) { | ||
| return; | ||
| } | ||
| if (expenseReport.policyID && shouldRestrictUserBillableActions(expenseReport.policyID)) { | ||
| if (expenseReport.policyID && shouldRestrictUserBillableActions(expenseReport.policyID, userBillingGraceEndPeriodCollection)) { | ||
| Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(expenseReport.policyID)); | ||
| return; | ||
| } | ||
|
|
@@ -11931,8 +11934,21 @@ | |
| } | ||
|
|
||
| function payMoneyRequest(params: PayMoneyRequestFunctionParams) { | ||
| const {paymentType, chatReport, iouReport, introSelected, iouReportCurrentNextStepDeprecated, currentUserAccountID, paymentPolicyID, full = true, activePolicy, policy, betas} = params; | ||
| if (chatReport.policyID && shouldRestrictUserBillableActions(chatReport.policyID)) { | ||
| const { | ||
| paymentType, | ||
| chatReport, | ||
| iouReport, | ||
| introSelected, | ||
| iouReportCurrentNextStepDeprecated, | ||
| currentUserAccountID, | ||
| paymentPolicyID, | ||
| userBillingGraceEndPeriodCollection, | ||
| full = true, | ||
| activePolicy, | ||
| policy, | ||
| betas, | ||
| } = params; | ||
| if (chatReport.policyID && shouldRestrictUserBillableActions(chatReport.policyID, userBillingGraceEndPeriodCollection)) { | ||
| Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(chatReport.policyID)); | ||
| return; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
confirmPaymentnow readsuserBillingGraceEndPeriodCollectionwhen callingpayMoneyRequest, but theuseCallbackdependency list was not updated. If this Onyx collection isundefinedon first render and arrives later, the memoized handler keeps the stale value and can continue using the fallback path inshouldRestrictUserBillableActions, allowing restricted users to initiate pay actions from this preview until another dependency changes and recreates the callback.Useful? React with 👍 / 👎.