Repository navigation
Refresh billing NVPs on restricted action page mount - #83568
Conversation
When users land on the restricted action page, the billing NVP data in Onyx may be stale (e.g., workspace owner paid their bill but the client cache was never updated because there is no Pusher event for billing NVP changes). This causes the restriction to persist incorrectly. Call openSubscriptionPage() on mount to fetch fresh billing NVPs from the server. Watch the billing Onyx keys so the component re-renders when fresh data arrives. If the fresh data shows the restriction no longer applies, automatically navigate the user back. Co-authored-by: Rushat Gabhane <rushatgabhane@users.noreply.github.com>
- Replace namespace import with named imports from @libs/PolicyUtils - Use CONST.DEFAULT_NUMBER_ID instead of -1 literal Co-authored-by: Rushat Gabhane <rushatgabhane@users.noreply.github.com>
|
Fixed the failing
|
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
|
@MelvinBot this seems like a bad UX? |
|
That's a fair concern. Looking at the current implementation, the UX flow when billing has already been resolved is:
The user briefly sees a "your workspace is restricted" page that then vanishes, and they have to retry whatever they were trying to do. That flash of alarming UI for a problem that's already been resolved isn't great. A couple of alternative approaches that could improve this:
Option 2 would be the least invasive change to this PR — adding a loading state while the fresh billing data is in flight, and only showing the restriction UI once the data is confirmed current. |
|
@MelvinBot let's go with option 2 |
Instead of immediately rendering the restriction UI (which may no longer apply due to stale cached data), show a FullScreenLoadingIndicator while fresh billing data is fetched from the server. The restriction page is only shown after confirming the restriction still applies, and if the restriction has been resolved, the user is navigated back without ever seeing the alarming restriction UI. Co-authored-by: Rushat Gabhane <rushatgabhane@users.noreply.github.com>
|
Implemented option 2. The page now shows a How it works:
|
@MelvinBot nahh don't add hacks please |
Use optimisticData/successData/failureData on openSubscriptionPage to track loading state via IS_LOADING_SUBSCRIPTION_DATA, instead of a 3-second setTimeout fallback. Co-authored-by: Rushat Gabhane <rushatgabhane@users.noreply.github.com>
|
Fair point. Replaced the timeout with a proper Onyx loading key ( How it works now:
|
|
fantastic! mark it ready for review @MelvinBot |
|
Done — PR has been marked as ready for review. |
|
@DylanDylann Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
|
@eVoloshchak Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6865991772
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| return; | ||
| } | ||
| if (!shouldRestrictUserBillableActions(policyID, userBillingGracePeriodCollection)) { | ||
| Navigation.goBack(); |
There was a problem hiding this comment.
Add fallback navigation when restriction is cleared
Calling Navigation.goBack() here can be a no-op when this screen is opened directly (e.g., deep link or browser refresh) because there is no back stack; goBack returns early when canGoBack() is false (src/libs/Navigation/Navigation.ts). In that case, even after fresh billing data shows the workspace is no longer restricted, the user stays on the restricted-action page instead of being returned to an accessible route.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Thanks for flagging this. After investigating, the concern does not apply here.
The WorkspaceRestrictedActionPage lives inside the RIGHT_MODAL_NAVIGATOR (RHP). The Expensify navigation system guarantees a back stack always exists for RHP screens, even when opened via deep link or browser refresh.
The key is in src/libs/Navigation/helpers/getAdaptedStateFromPath.ts (lines 317-321):
const isRightModalNavigator = state.routes.find((route) => route.name === NAVIGATORS.RIGHT_MODAL_NAVIGATOR);
if (isRightModalNavigator) {
return getRoutesWithIndex([{name: NAVIGATORS.REPORTS_SPLIT_NAVIGATOR}, ...state.routes]);
}This adapter is registered as the global getStateFromPath in the linking config (src/libs/Navigation/linkingConfig/index.ts, line 9), so every URL — deep link, browser refresh, or direct entry — goes through it. When the URL resolves to an RHP route, a REPORTS_SPLIT_NAVIGATOR base route is automatically prepended to the stack.
So even when navigating directly to restricted-action/workspace/:policyID, the navigation state will always be: [REPORTS_SPLIT_NAVIGATOR, RIGHT_MODAL_NAVIGATOR], meaning canGoBack() returns true and goBack() successfully dismisses the modal.
No fallback route is needed.
|
The only failing check is the PR Reviewer Checklist ( This is not a code issue — all code-related checks (ESLint, typecheck, Prettier, tests, builds, spellcheck, signed commits, etc.) are passing. The reviewer checklist check will resolve once a reviewer posts their checklist. |
|
This PR is already marked as ready for review — it's not in draft state, so no change is needed. |
|
@shubham1206agra Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
|
@youssef-lr Checklist here #83568 (comment) |
|
🚧 @lakchote has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/lakchote in version: 9.3.33-0 🚀
|
|
@lakchote @rushatgabhane @heyjennahay @youssef-lr Can this PR please be tested internally, Adding billing is not possible for applause testers. |
|
🚀 Deployed to production by https://github.com/luacmartins in version: 9.3.33-5 🚀
|
Explanation of Change
When the
WorkspaceRestrictedActionPagemounts, the billing NVP data (NVP_PRIVATE_AMOUNT_OWED,NVP_PRIVATE_OWNER_BILLING_GRACE_PERIOD_END, shared grace period collection) may be stale in Onyx. This causes the workspace restriction to persist even after the workspace owner has resolved their billing issue.The stale data problem occurs because:
OpenApp/ReconnectApp(sign-out/sign-in) orOpenSubscriptionPageThis PR adds a fresh billing NVP fetch when the restricted action page mounts by calling
openSubscriptionPage(). It also watches the billing Onyx keys so the component re-renders when fresh data arrives. If the fresh server data shows the restriction no longer applies (i.e.shouldRestrictUserBillableActionsreturnsfalse), the user is automatically navigated back.This follows the same pattern already used by
SubscriptionSettingsPagewhich callsopenSubscriptionPage()on mount.Fixed Issues
$ https://github.com/Expensify/Expensify/issues/597281
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
N/A - no UI changes, only data fetching behavior change
Android: mWeb Chrome
N/A - no UI changes, only data fetching behavior change
iOS: Native
N/A - no UI changes, only data fetching behavior change
iOS: mWeb Safari
N/A - no UI changes, only data fetching behavior change
MacOS: Chrome / Safari
N/A - no UI changes, only data fetching behavior change