Skip to content

Moved auth only providers to AuthScreen#86441

Merged
roryabraham merged 8 commits intoExpensify:mainfrom
shubham1206agra:rearrange-providers
Apr 15, 2026
Merged

Moved auth only providers to AuthScreen#86441
roryabraham merged 8 commits intoExpensify:mainfrom
shubham1206agra:rearrange-providers

Conversation

@shubham1206agra
Copy link
Copy Markdown
Contributor

@shubham1206agra shubham1206agra commented Mar 26, 2026

Explanation of Change

Fixed Issues

$ #86458

Tests

  1. Open App
  2. Go to any expense report
  3. Verify that it opens correctly
  4. Go to any chat with video.
  5. Verify that the video works correctly in all layouts.
  • Verify that no errors appear in the JS console

Offline tests

Same as Tests

QA Steps

Same as Tests

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I verified there are no new alerts related to the canBeMissing param for useOnyx
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Screen.Recording.2026-03-28.at.1.53.03.PM.mov

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 26, 2026

Codecov Report

✅ Changes either increased or maintained existing code coverage, great job!

Files with missing lines Coverage Δ
src/App.tsx 100.00% <ø> (ø)
src/libs/Navigation/AppNavigator/AuthScreens.tsx 83.14% <100.00%> (+0.19%) ⬆️
src/components/SupportalPermissionDeniedModal.tsx 80.00% <80.00%> (ø)
... and 20 files with indirect coverage changes

@shubham1206agra shubham1206agra marked this pull request as ready for review March 28, 2026 08:26
@shubham1206agra shubham1206agra requested review from a team as code owners March 28, 2026 08:26
@melvin-bot melvin-bot Bot requested review from huult and trjExpensify March 28, 2026 08:26
@melvin-bot
Copy link
Copy Markdown

melvin-bot Bot commented Mar 28, 2026

@huult 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]

@melvin-bot melvin-bot Bot requested review from a team, Julesssss and thesahindia and removed request for a team March 28, 2026 08:26
@melvin-bot
Copy link
Copy Markdown

melvin-bot Bot commented Mar 28, 2026

@thesahindia @Julesssss One of you needs to 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]

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ffc6d60752

ℹ️ 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".

Comment thread src/libs/Navigation/AppNavigator/AuthScreens.tsx
Comment thread src/libs/Navigation/AppNavigator/AuthScreens.tsx
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adhorodyski Can I move this component inside ComposeProviders? To fix https://github.com/Expensify/App/pull/86441/changes#r3004502757 and https://github.com/Expensify/App/pull/86441/changes#r3004502759

Asking you since you authored #84052

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

KeyboardShortcutsHandler? I believe so, I don't see why not.

Comment thread src/libs/Navigation/AppNavigator/AuthScreens.tsx
@trjExpensify trjExpensify removed their request for review March 30, 2026 21:09
@trjExpensify
Copy link
Copy Markdown
Contributor

PR doesn’t need product input as a refactor PR. Unassigning and unsubscribing myself.

@MelvinBot
Copy link
Copy Markdown
Contributor

Here's the full analysis of all Providers in AuthScreens.

Providers in AuthScreens (19 total)

Moved from App.tsxAuthScreens in this PR (12 providers)

These were previously in the top-level App.tsx ComposeProviders but are only consumed by authenticated screens, so moving them here is correct scoping:

# Provider Purpose Consumers
1 AttachmentModalContextProvider Manages attachment visibility/state across report screens Attachment modal screens
2 PlaybackContextProvider Central video playback state, cross-report video sharing Video player components
3 VolumeContextProvider Shared video volume state with persistence Video player controls
4 VideoPopoverMenuContextProvider Playback speed settings, download options Video popover menu
5 FullScreenContextProvider Fullscreen state and layout locking for video Video fullscreen mode
6 SearchRouterContextProvider Global search modal visibility, keyboard shortcuts Search router, command palette
7 ProductTrainingContextProvider Priority-based onboarding tooltips Product training tooltips
8 ExpensifyCardContextProvider Revealed card details, loading/error states Wallet/card settings pages
9 TravelCVVContextProvider Travel card CVV (in-memory only, never persisted) Travel CVV page
10 KYCWallContextProvider Ref-based access to KYC verification modal KYC wall trigger components
11 WideRHPContextProvider Wide/Super-Wide Right Hand Panel display, sizing, animations Right modal navigator, receipt pane
12 KeyboardDismissibleFlatListContextProvider Keyboard-aware list scrolling (Reanimated shared values) Chat list, report action list

Already in AuthScreens on main (7 providers)

# Provider Purpose Consumers
13 CurrencyListContextProvider Currency symbols and decimal formatting (from Onyx) Amount inputs, expense displays
14 OptionsListContextProvider Computed list of selectable reports/contacts for autocomplete Participant/recipient selection
15 SidebarOrderedReportsContextProvider Sorted/filtered report list for LHN with caching Left Hand Navigation sidebar
16 SearchContextProvider Search state, results, selected transactions Search results page
17 LockedAccountModalProvider Locked account modal display Account lock warning
18 DelegateNoAccessModalProvider Modal for restricted delegate actions Delegate access checks
19 SupportalPermissionDeniedModalProvider Modal for Supportal permission denied states Supportal permission checks

Provider Dependency Groups

  • Video cluster (2→5): PlaybackContextVolume, VideoPopoverMenu, FullScreen — tightly coupled, order matters
  • Search cluster (6, 14, 16): SearchRouterContext + OptionsListContext + SearchContext — work together for search flows
  • Wallet cluster (8, 9, 10): ExpensifyCard + TravelCVV + KYCWall — all wallet/payment-related
  • Modal cluster (17, 18, 19): LockedAccount + DelegateNoAccess + SupportalPermissionDenied — UI state for restriction modals

Key Observation

All 19 providers are exclusively consumed by authenticated screens — none are needed for the unauthenticated/login flow. Moving the 12 providers from App.tsx into AuthScreens is a clean scoping improvement: these contexts won't be initialized until the user is actually authenticated, avoiding unnecessary provider setup during the login flow.

@shubham1206agra
Copy link
Copy Markdown
Contributor Author

@MelvinBot Can you find if we can move down any of these providers?

@MelvinBot
Copy link
Copy Markdown
Contributor

I traced all consumers of each of the 19 providers in AuthScreens to determine which can be moved to a narrower scope. Here's the summary:

Providers That CAN Be Moved Down

Provider Consumers Current Scope Can Move To
ExpensifyCardContextProvider 2 Entire auth tree Settings Wallet RHP / DomainCard RHP only
TravelCVVContextProvider 2 Entire auth tree Settings Wallet RHP only
KeyboardDismissibleFlatListContextProvider 2 Entire auth tree Self-contained within the KeyboardDismissibleFlatList component itself
SupportalPermissionDeniedModalProvider 0 Entire auth tree Not a real context provider — could be a standalone sibling component

Details on each:

1. ExpensifyCardContextProvider — Only consumed by ExpensifyCardPage and ExpensifyCardVerifyAccountPage, both exclusively in Settings Wallet RHP (SCREENS.SETTINGS.WALLET.DOMAIN_CARD*) and the DomainCard RHP modal (SCREENS.DOMAIN_CARD.*). It shares revealed card details between the card page and its magic-code verification sub-page. Could be moved to wrap just those screen groups.

2. TravelCVVContextProvider — Strongest candidate. Only consumed by TravelCVVPage and TravelCVVVerifyAccountPage, both in the same Settings Wallet RHP stack (SCREENS.SETTINGS.WALLET.TRAVEL_CVV*). The context passes ephemeral CVV data between siblings in the exact same navigator.

3. KeyboardDismissibleFlatListContextProvider — Only consumed internally by KeyboardDismissibleFlatList/index.ios.tsx and KeyboardDismissibleFlatList/index.tsx. No external consumers. The provider could be self-contained within the component rather than wrapping the entire auth tree. (Caveat: keeping it at root may be intentional if a single shared keyboard state instance across all FlatLists is desired.)

4. SupportalPermissionDeniedModalProvider — Has zero context consumers. It exports no hooks, no context, and no state. It's purely an Onyx-driven ConfirmModal wrapper:

function SupportalPermissionDeniedModalProvider({children}) {
    const [payload] = useOnyx(ONYXKEYS.SUPPORTAL_PERMISSION_DENIED);
    return <>{children}<ConfirmModal isVisible={!!payload} .../></>;
}

This doesn't need to be a provider at all — it could be rendered as a standalone sibling component, eliminating one nesting level.


Providers That CANNOT Be Moved Down

Provider Consumers Why It Needs Root Scope
AttachmentModalContextProvider 8 Reports, Settings, Share modal, 8+ root-level attachment modal screens
PlaybackContextProvider 7 Reports, Search, attachment modals, FeatureTrainingModal, Share modal
VolumeContextProvider 2 Wherever BaseVideoPlayer renders (reports, search, modals, share)
VideoPopoverMenuContextProvider 2 Same as VolumeContext — wherever BaseVideoPlayer renders
FullScreenContextProvider 3 direct + 64 indirect Consumed by useWindowDimensionsuseResponsiveLayout used everywhere (though has ?? fallback)
SearchRouterContextProvider 6 SearchButton in every TopBar sidebar + SearchRouterModal outside navigators
ProductTrainingContextProvider 9 LHN sidebar, search, IOU flows, account switcher — manages global tooltip priority
SearchContextProvider 40+ Reports central pane, Search fullscreen, RHP, Settings, SearchRouter overlay
OptionsListContextProvider 15+ SearchRouter, Search filters, IOU flows, onboarding, workspace, settings
SidebarOrderedReportsContextProvider 5 NavigationTabBar in every split navigator + PriorityModeController outside navigators
CurrencyListContextProvider 30+ Settings, workspace, IOU, search, onboarding, shared components
WideRHPContextProvider 20+ Navigation infrastructure (RightModalNavigator), reports, search, RHP screens
KYCWallContextProvider 9 Reports, Search, Settings, EnablePayments modal, bank account flows
LockedAccountModalProvider 15 Settings, workspace, search, report headers
DelegateNoAccessModalProvider 34+ Most widely consumed — virtually every navigator subtree

TL;DR: 4 of 19 providers can be moved down or refactored: TravelCVVContextProvider and ExpensifyCardContextProvider (wallet-only scope), KeyboardDismissibleFlatListContextProvider (self-contained), and SupportalPermissionDeniedModalProvider (not a real provider). The other 15 genuinely need root-level scope.

showSupportalPermissionDeniedModal(supportalPermissionDeniedPayload.command);
}, [supportalPermissionDeniedPayload]);

return null;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A component that only ever returns null is a code smell. At that point, it should just be a hook. But in this case, it's only used in one place, so I'm not sure it really should be a custom hook vs just inlined in the only component it's used in. I don't feel strongly if you want to keep it encapsulated in a custom hook for organizational purposes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@roryabraham I think @adhorodyski can comment on this better, as he did the original change, and we are using this pattern at many places in the codebase.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, we can see what @adhorodyski has to say about it

Copy link
Copy Markdown
Contributor

@adhorodyski adhorodyski Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please look into Expensify.tsx or DelegateAccessHandler.tsx (and others) as examples - I wouldn't say it's a direct code smell, because JSX nodes often provide a genuinely better separation than hooks. The official docs state it clearly as a valid JSX return for the old render method, we're just more used to seeing it as an early return rather than the final state.

An additional JSX node is cheap to reconcile, separates itself from the parent when previewed with a profiler and can be rendered optionally which is something we cannot do with hooks. In my view it just helps organize the behavior with JSX in a declarative way (but we have to remember to not overuse it).

I cannot find the exact PRs of mine but had numerous discussions about this already and the truth is it all depends on what we're trying to achieve.

Looking at this specific case, we want to open a modal on an Onyx value change, which is a weird mix. I understand it was previously implemented this way, but is there no event that we can use to fire it based on this action? Both context provider and a renderless component/hook seem wrong to me here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Historically I found it useful to be able to declare a renderless <SynchronizeSystemX /> component that separates some API conversations, without a hook. I hate to say it, but it all depends - in your position I'd look into when we actually want to open up a modal instead of rewriting X to Z for the sake of it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An additional JSX node is cheap to reconcile, separates itself from the parent when previewed with a profiler and can be rendered optionally which is something we cannot do with hooks

Interesting points.

@github-actions
Copy link
Copy Markdown
Contributor

🚧 @roryabraham has triggered a test Expensify/App build. You can view the workflow run here.

Copy link
Copy Markdown
Contributor

@roryabraham roryabraham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍🏼

@github-actions

This comment has been minimized.

@huult
Copy link
Copy Markdown
Contributor

huult commented Apr 13, 2026

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Screen.Recording.2026-04-15.at.11.28.10.mp4

@huult
Copy link
Copy Markdown
Contributor

huult commented Apr 13, 2026

@shubham1206agra Could you please add video to both mWeb and the native app?

@huult
Copy link
Copy Markdown
Contributor

huult commented Apr 13, 2026

KeyboardDismissibleFlatListContextProvider
KYCWallContextProvider
ProductTrainingContextProvider
SearchRouterContextProvider
SupportalPermissionDeniedModal
FullScreenContextProvider
PlaybackContextProvider
VideoPopoverMenuContextProvider
VolumeContextProvider
WideRHPContextProvider
AttachmentModalContextProvider
ExpensifyCardContextProvider
TravelCVVContextProvider

@shubham1206agra Could you add test steps to verify which features are impacted by moving the provider from App to AuthScreen? We should cover key cases to ensure the provider works correctly and prevent any component rendering issues outside it.

@shubham1206agra
Copy link
Copy Markdown
Contributor Author

@MelvinBot Can you write a test case for each provider?

KeyboardDismissibleFlatListContextProvider
KYCWallContextProvider
ProductTrainingContextProvider
SearchRouterContextProvider
SupportalPermissionDeniedModal
FullScreenContextProvider
PlaybackContextProvider
VideoPopoverMenuContextProvider
VolumeContextProvider
WideRHPContextProvider
AttachmentModalContextProvider
ExpensifyCardContextProvider
TravelCVVContextProvider

@shubham1206agra
Copy link
Copy Markdown
Contributor Author

@shubham1206agra Could you please add video to both mWeb and the native app?

@huult The web recording is sufficient in this case. You can check if you want

@MelvinBot
Copy link
Copy Markdown
Contributor

Here are test cases for each of the 13 providers/components listed. Since I'm not an assignee on this PR, I can't push directly — but here are the complete tests you can add.

Note: ProductTrainingContextProvider already has tests at tests/ui/components/ProductTrainingContextProvider.tsx, so I've included only a minimal placeholder for it below. SupportalPermissionDeniedModal is not a provider (it's a component that renders null), so the test validates its modal-triggering behavior instead.

tests/ui/components/KeyboardDismissibleFlatListContextProviderTest.tsx
import {renderHook} from '@testing-library/react-native';
import Onyx from 'react-native-onyx';
import {
    KeyboardDismissibleFlatListContextProvider,
    useKeyboardDismissibleFlatListState,
    useKeyboardDismissibleFlatListActions,
} from '@components/KeyboardDismissibleFlatList/KeyboardDismissibleFlatListContext';
import ONYXKEYS from '@src/ONYXKEYS';
import waitForBatchedUpdatesWithAct from '../../utils/waitForBatchedUpdatesWithAct';
import wrapOnyxWithWaitForBatchedUpdates from '../../utils/wrapOnyxWithWaitForBatchedUpdates';

const wrapper = ({children}: {children: React.ReactNode}) => (
    <KeyboardDismissibleFlatListContextProvider>{children}</KeyboardDismissibleFlatListContextProvider>
);

describe('KeyboardDismissibleFlatListContextProvider', () => {
    beforeAll(() => {
        Onyx.init({keys: ONYXKEYS});
        return waitForBatchedUpdatesWithAct();
    });

    beforeEach(() => {
        wrapOnyxWithWaitForBatchedUpdates(Onyx);
    });

    afterEach(async () => {
        await Onyx.clear();
        await waitForBatchedUpdatesWithAct();
    });

    it('should provide state context with shared values', () => {
        const {result} = renderHook(() => useKeyboardDismissibleFlatListState(), {wrapper});

        expect(result.current.keyboardHeight).toBeDefined();
        expect(result.current.keyboardOffset).toBeDefined();
        expect(result.current.scrollY).toBeDefined();
        expect(result.current.contentSizeHeight).toBeDefined();
        expect(result.current.layoutMeasurementHeight).toBeDefined();
    });

    it('should provide actions context with onScroll and setListBehavior', () => {
        const {result} = renderHook(() => useKeyboardDismissibleFlatListActions(), {wrapper});

        expect(result.current.onScroll).toBeDefined();
        expect(typeof result.current.setListBehavior).toBe('function');
    });
});
tests/ui/components/KYCWallContextProviderTest.tsx
import {renderHook} from '@testing-library/react-native';
import {useContext} from 'react';
import KYCWallContextProvider, {KYCWallContext} from '@components/KYCWall/KYCWallContext';

const wrapper = ({children}: {children: React.ReactNode}) => (
    <KYCWallContextProvider>{children}</KYCWallContextProvider>
);

describe('KYCWallContextProvider', () => {
    it('should provide a ref object', () => {
        const {result} = renderHook(() => useContext(KYCWallContext), {wrapper});

        expect(result.current).toHaveProperty('current');
        expect(result.current.current).toBeNull();
    });

    it('should provide same ref instance across re-renders', () => {
        const {result, rerender} = renderHook(() => useContext(KYCWallContext), {wrapper});

        const firstRef = result.current;
        rerender({});
        expect(result.current).toBe(firstRef);
    });
});
tests/ui/components/ProductTrainingContextProviderTest.tsx (already exists)

This provider already has comprehensive tests at tests/ui/components/ProductTrainingContextProvider.tsx covering registration, dismissal, layout-specific behavior, and priority handling. No additional tests needed.

tests/ui/components/SearchRouterContextProviderTest.tsx
import {renderHook, act} from '@testing-library/react-native';
import {SearchRouterContextProvider, useSearchRouterState, useSearchRouterActions} from '@components/Search/SearchRouter/SearchRouterContext';

jest.mock('@userActions/Modal', () => ({
    close: (callback: () => void) => callback(),
}));

jest.mock('@libs/Navigation/helpers/isSearchTopmostFullScreenRoute', () => ({
    __esModule: true,
    default: jest.fn(() => false),
}));

jest.mock('@libs/Navigation/Navigation', () => ({
    navigationRef: {
        getRootState: jest.fn(() => ({routes: []})),
    },
}));

jest.mock('@libs/telemetry/activeSpans', () => ({
    startSpan: jest.fn(),
    endSpan: jest.fn(),
    cancelSpan: jest.fn(),
    getSpan: jest.fn(),
}));

const wrapper = ({children}: {children: React.ReactNode}) => (
    <SearchRouterContextProvider>{children}</SearchRouterContextProvider>
);

describe('SearchRouterContextProvider', () => {
    it('should initialize with search router not displayed', () => {
        const {result} = renderHook(() => useSearchRouterState(), {wrapper});

        expect(result.current.isSearchRouterDisplayed).toBe(false);
    });

    it('should provide all action methods', () => {
        const {result} = renderHook(() => useSearchRouterActions(), {wrapper});

        expect(typeof result.current.openSearchRouter).toBe('function');
        expect(typeof result.current.closeSearchRouter).toBe('function');
        expect(typeof result.current.toggleSearch).toBe('function');
        expect(typeof result.current.registerSearchPageInput).toBe('function');
        expect(typeof result.current.unregisterSearchPageInput).toBe('function');
    });

    it('should open and close search router', () => {
        const {result} = renderHook(
            () => ({
                state: useSearchRouterState(),
                actions: useSearchRouterActions(),
            }),
            {wrapper},
        );

        expect(result.current.state.isSearchRouterDisplayed).toBe(false);

        act(() => {
            result.current.actions.openSearchRouter();
        });

        expect(result.current.state.isSearchRouterDisplayed).toBe(true);

        act(() => {
            result.current.actions.closeSearchRouter();
        });

        expect(result.current.state.isSearchRouterDisplayed).toBe(false);
    });
});
tests/ui/components/SupportalPermissionDeniedModalTest.tsx
import {render} from '@testing-library/react-native';
import Onyx from 'react-native-onyx';
import SupportalPermissionDeniedModal from '@components/SupportalPermissionDeniedModal';
import ONYXKEYS from '@src/ONYXKEYS';
import waitForBatchedUpdatesWithAct from '../../utils/waitForBatchedUpdatesWithAct';
import wrapOnyxWithWaitForBatchedUpdates from '../../utils/wrapOnyxWithWaitForBatchedUpdates';

const mockShowConfirmModal = jest.fn(() => Promise.resolve());
jest.mock('@hooks/useConfirmModal', () => ({
    __esModule: true,
    default: () => ({showConfirmModal: mockShowConfirmModal}),
}));

jest.mock('@userActions/App', () => ({
    clearSupportalPermissionDenied: jest.fn(),
}));

describe('SupportalPermissionDeniedModal', () => {
    beforeAll(() => {
        Onyx.init({keys: ONYXKEYS});
        return waitForBatchedUpdatesWithAct();
    });

    beforeEach(() => {
        wrapOnyxWithWaitForBatchedUpdates(Onyx);
        mockShowConfirmModal.mockClear();
    });

    afterEach(async () => {
        await Onyx.clear();
        await waitForBatchedUpdatesWithAct();
    });

    it('should render null', () => {
        const {toJSON} = render(<SupportalPermissionDeniedModal />);
        expect(toJSON()).toBeNull();
    });

    it('should show confirm modal when supportal permission denied payload is set', async () => {
        render(<SupportalPermissionDeniedModal />);

        Onyx.merge(ONYXKEYS.SUPPORTAL_PERMISSION_DENIED, {command: 'TestCommand'});
        await waitForBatchedUpdatesWithAct();

        expect(mockShowConfirmModal).toHaveBeenCalledWith(
            expect.objectContaining({
                shouldShowCancelButton: false,
            }),
        );
    });

    it('should not show modal when payload is not set', () => {
        render(<SupportalPermissionDeniedModal />);

        expect(mockShowConfirmModal).not.toHaveBeenCalled();
    });
});
tests/ui/components/FullScreenContextProviderTest.tsx
import {renderHook, act} from '@testing-library/react-native';
import FullScreenContextProvider, {useFullScreenState, useFullScreenActions} from '@components/VideoPlayerContexts/FullScreenContextProvider';

const wrapper = ({children}: {children: React.ReactNode}) => (
    <FullScreenContextProvider>{children}</FullScreenContextProvider>
);

describe('FullScreenContextProvider', () => {
    it('should provide state with refs', () => {
        const {result} = renderHook(() => useFullScreenState(), {wrapper});

        expect(result.current.isFullScreenRef).toBeDefined();
        expect(result.current.isFullScreenRef.current).toBe(false);
        expect(result.current.lockedWindowDimensionsRef).toBeDefined();
        expect(result.current.lockedWindowDimensionsRef.current).toBeNull();
    });

    it('should lock and unlock window dimensions', () => {
        const {result} = renderHook(
            () => ({
                state: useFullScreenState(),
                actions: useFullScreenActions(),
            }),
            {wrapper},
        );

        const mockDimensions = {
            shouldUseNarrowLayout: false,
            isSmallScreenWidth: false,
            isInNarrowPaneModal: false,
            isExtraSmallScreenHeight: false,
            isMediumScreenWidth: false,
            isLargeScreenWidth: true,
            isExtraSmallScreenWidth: false,
            isSmallScreen: false,
            onboardingIsMediumOrLargerScreenWidth: true,
            isExtraLargeScreenWidth: false,
            isInLandscapeMode: false,
        };

        act(() => {
            result.current.actions.lockWindowDimensions(mockDimensions);
        });

        expect(result.current.state.lockedWindowDimensionsRef.current).toEqual(mockDimensions);

        act(() => {
            result.current.actions.unlockWindowDimensions();
        });

        expect(result.current.state.lockedWindowDimensionsRef.current).toBeNull();
    });

    it('should throw when useFullScreenState is used outside provider', () => {
        expect(() => {
            renderHook(() => useFullScreenState());
        }).toThrow('useFullScreenState must be used within a FullScreenContextProvider');
    });

    it('should throw when useFullScreenActions is used outside provider', () => {
        expect(() => {
            renderHook(() => useFullScreenActions());
        }).toThrow('useFullScreenActions must be used within a FullScreenContextProvider');
    });
});
tests/ui/components/PlaybackContextProviderTest.tsx
import {renderHook} from '@testing-library/react-native';
import {PlaybackContextProvider, usePlaybackStateContext, usePlaybackActionsContext} from '@components/VideoPlayerContexts/PlaybackContext';

jest.mock('@libs/ReportUtils', () => ({
    getReportOrDraftReport: jest.fn(),
    isChatThread: jest.fn(() => false),
}));

jest.mock('@navigation/Navigation', () => ({
    isNavigationReady: jest.fn(() => Promise.resolve()),
}));

const wrapper = ({children}: {children: React.ReactNode}) => (
    <PlaybackContextProvider>{children}</PlaybackContextProvider>
);

describe('PlaybackContextProvider', () => {
    it('should provide initial state values', () => {
        const {result} = renderHook(() => usePlaybackStateContext(), {wrapper});

        expect(result.current.currentlyPlayingURL).toBeNull();
        expect(result.current.originalParent).toBeNull();
        expect(result.current.sharedElement).toBeNull();
        expect(result.current.currentVideoPlayerRef).toBeDefined();
        expect(result.current.currentVideoViewRef).toBeDefined();
        expect(result.current.mountedVideoPlayersRef).toBeDefined();
        expect(result.current.playerStatus).toBeDefined();
        expect(result.current.shareVersion).toBe(0);
    });

    it('should provide all action methods', () => {
        const {result} = renderHook(() => usePlaybackActionsContext(), {wrapper});

        expect(typeof result.current.updateCurrentURLAndReportID).toBe('function');
        expect(typeof result.current.shareVideoPlayerElements).toBe('function');
        expect(typeof result.current.setCurrentlyPlayingURL).toBe('function');
        expect(typeof result.current.playVideo).toBe('function');
        expect(typeof result.current.pauseVideo).toBe('function');
        expect(typeof result.current.replayVideo).toBe('function');
        expect(typeof result.current.stopVideo).toBe('function');
        expect(typeof result.current.checkIfVideoIsPlaying).toBe('function');
        expect(typeof result.current.resetVideoPlayerData).toBe('function');
        expect(typeof result.current.updatePlayerStatus).toBe('function');
        expect(typeof result.current.requestDonorReRegistration).toBe('function');
    });

    it('should throw when usePlaybackStateContext is used outside provider', () => {
        expect(() => {
            renderHook(() => usePlaybackStateContext());
        }).toThrow('usePlaybackStateContext must be used within a PlaybackContextProvider');
    });

    it('should throw when usePlaybackActionsContext is used outside provider', () => {
        expect(() => {
            renderHook(() => usePlaybackActionsContext());
        }).toThrow('usePlaybackActionsContext must be used within a PlaybackContextProvider');
    });
});
tests/ui/components/VideoPopoverMenuContextProviderTest.tsx
import {renderHook} from '@testing-library/react-native';
import {PlaybackContextProvider} from '@components/VideoPlayerContexts/PlaybackContext';
import {VideoPopoverMenuContextProvider, useVideoPopoverMenuState, useVideoPopoverMenuActions} from '@components/VideoPlayerContexts/VideoPopoverMenuContext';

jest.mock('@libs/ReportUtils', () => ({
    getReportOrDraftReport: jest.fn(),
    isChatThread: jest.fn(() => false),
}));

jest.mock('@navigation/Navigation', () => ({
    isNavigationReady: jest.fn(() => Promise.resolve()),
}));

const wrapper = ({children}: {children: React.ReactNode}) => (
    <PlaybackContextProvider>
        <VideoPopoverMenuContextProvider>{children}</VideoPopoverMenuContextProvider>
    </PlaybackContextProvider>
);

describe('VideoPopoverMenuContextProvider', () => {
    it('should provide menu items', () => {
        const {result} = renderHook(() => useVideoPopoverMenuState(), {wrapper});

        expect(result.current.menuItems).toBeDefined();
        expect(Array.isArray(result.current.menuItems)).toBe(true);
    });

    it('should provide action methods', () => {
        const {result} = renderHook(() => useVideoPopoverMenuActions(), {wrapper});

        expect(typeof result.current.updateVideoPopoverMenuPlayerRef).toBe('function');
        expect(typeof result.current.updatePlaybackSpeed).toBe('function');
        expect(typeof result.current.updateSource).toBe('function');
    });

    it('should throw when useVideoPopoverMenuState is used outside provider', () => {
        expect(() => {
            renderHook(() => useVideoPopoverMenuState());
        }).toThrow('useVideoPopoverMenuState must be used within a VideoPopoverMenuContextProvider');
    });

    it('should throw when useVideoPopoverMenuActions is used outside provider', () => {
        expect(() => {
            renderHook(() => useVideoPopoverMenuActions());
        }).toThrow('useVideoPopoverMenuActions must be used within a VideoPopoverMenuContextProvider');
    });
});
tests/ui/components/VolumeContextProviderTest.tsx
import {renderHook} from '@testing-library/react-native';
import {PlaybackContextProvider} from '@components/VideoPlayerContexts/PlaybackContext';
import {VolumeContextProvider, useVolumeState, useVolumeActions} from '@components/VideoPlayerContexts/VolumeContext';

jest.mock('@libs/ReportUtils', () => ({
    getReportOrDraftReport: jest.fn(),
    isChatThread: jest.fn(() => false),
}));

jest.mock('@navigation/Navigation', () => ({
    isNavigationReady: jest.fn(() => Promise.resolve()),
}));

const wrapper = ({children}: {children: React.ReactNode}) => (
    <PlaybackContextProvider>
        <VolumeContextProvider>{children}</VolumeContextProvider>
    </PlaybackContextProvider>
);

describe('VolumeContextProvider', () => {
    it('should provide volume shared values', () => {
        const {result} = renderHook(() => useVolumeState(), {wrapper});

        expect(result.current.volume).toBeDefined();
        expect(result.current.lastNonZeroVolume).toBeDefined();
    });

    it('should provide action methods', () => {
        const {result} = renderHook(() => useVolumeActions(), {wrapper});

        expect(typeof result.current.updateVolume).toBe('function');
        expect(typeof result.current.toggleMute).toBe('function');
    });

    it('should throw when useVolumeState is used outside provider', () => {
        expect(() => {
            renderHook(() => useVolumeState());
        }).toThrow('useVolumeState must be used within a VolumeContextProvider');
    });

    it('should throw when useVolumeActions is used outside provider', () => {
        expect(() => {
            renderHook(() => useVolumeActions());
        }).toThrow('useVolumeActions must be used within a VolumeContextProvider');
    });
});
tests/ui/components/WideRHPContextProviderTest.tsx
import {renderHook, act} from '@testing-library/react-native';
import Onyx from 'react-native-onyx';
import WideRHPContextProvider, {useWideRHPState, useWideRHPActions} from '@components/WideRHPContextProvider';
import ONYXKEYS from '@src/ONYXKEYS';
import waitForBatchedUpdatesWithAct from '../../utils/waitForBatchedUpdatesWithAct';
import wrapOnyxWithWaitForBatchedUpdates from '../../utils/wrapOnyxWithWaitForBatchedUpdates';

jest.mock('@hooks/useRootNavigationState', () => ({
    __esModule: true,
    default: jest.fn((selector) =>
        selector
            ? selector(undefined)
            : {focusedRoute: undefined, focusedNavigator: undefined},
    ),
}));

const wrapper = ({children}: {children: React.ReactNode}) => (
    <WideRHPContextProvider>{children}</WideRHPContextProvider>
);

describe('WideRHPContextProvider', () => {
    beforeAll(() => {
        Onyx.init({keys: ONYXKEYS});
        return waitForBatchedUpdatesWithAct();
    });

    beforeEach(() => {
        wrapOnyxWithWaitForBatchedUpdates(Onyx);
    });

    afterEach(async () => {
        await Onyx.clear();
        await waitForBatchedUpdatesWithAct();
    });

    it('should provide initial state with empty route keys', () => {
        const {result} = renderHook(() => useWideRHPState(), {wrapper});

        expect(result.current.wideRHPRouteKeys).toEqual([]);
        expect(result.current.superWideRHPRouteKeys).toEqual([]);
        expect(result.current.isWideRHPFocused).toBe(false);
        expect(result.current.isSuperWideRHPFocused).toBe(false);
    });

    it('should provide all action methods', () => {
        const {result} = renderHook(() => useWideRHPActions(), {wrapper});

        expect(typeof result.current.showWideRHPVersion).toBe('function');
        expect(typeof result.current.showSuperWideRHPVersion).toBe('function');
        expect(typeof result.current.removeWideRHPRouteKey).toBe('function');
        expect(typeof result.current.removeSuperWideRHPRouteKey).toBe('function');
        expect(typeof result.current.markReportIDAsExpense).toBe('function');
        expect(typeof result.current.markReportIDAsMultiTransactionExpense).toBe('function');
        expect(typeof result.current.unmarkReportIDAsMultiTransactionExpense).toBe('function');
        expect(typeof result.current.isReportIDMarkedAsExpense).toBe('function');
        expect(typeof result.current.isReportIDMarkedAsMultiTransactionExpense).toBe('function');
        expect(typeof result.current.syncRHPKeys).toBe('function');
        expect(typeof result.current.clearWideRHPKeys).toBe('function');
        expect(typeof result.current.setIsWideRHPClosing).toBe('function');
        expect(typeof result.current.setIsSuperWideRHPClosing).toBe('function');
    });

    it('should mark and check report IDs as expense', () => {
        const {result} = renderHook(
            () => ({
                actions: useWideRHPActions(),
            }),
            {wrapper},
        );

        expect(result.current.actions.isReportIDMarkedAsExpense('123')).toBe(false);

        act(() => {
            result.current.actions.markReportIDAsExpense('123');
        });

        expect(result.current.actions.isReportIDMarkedAsExpense('123')).toBe(true);
    });

    it('should mark and unmark report IDs as multi-transaction expense', () => {
        const {result} = renderHook(
            () => ({
                actions: useWideRHPActions(),
            }),
            {wrapper},
        );

        expect(result.current.actions.isReportIDMarkedAsMultiTransactionExpense('456')).toBe(false);

        act(() => {
            result.current.actions.markReportIDAsMultiTransactionExpense('456');
        });

        expect(result.current.actions.isReportIDMarkedAsMultiTransactionExpense('456')).toBe(true);

        act(() => {
            result.current.actions.unmarkReportIDAsMultiTransactionExpense('456');
        });

        expect(result.current.actions.isReportIDMarkedAsMultiTransactionExpense('456')).toBe(false);
    });
});
tests/ui/components/AttachmentModalContextProviderTest.tsx
import {renderHook, act} from '@testing-library/react-native';
import {useContext} from 'react';
import AttachmentModalContext, {AttachmentModalContextProvider} from '@pages/media/AttachmentModalScreen/AttachmentModalContext';

jest.mock('@hooks/useCurrentReportID', () => ({
    useCurrentReportIDState: jest.fn(() => ({currentReportID: '1'})),
}));

const wrapper = ({children}: {children: React.ReactNode}) => (
    <AttachmentModalContextProvider>{children}</AttachmentModalContextProvider>
);

describe('AttachmentModalContextProvider', () => {
    it('should provide context with default values', () => {
        const {result} = renderHook(() => useContext(AttachmentModalContext), {wrapper});

        expect(typeof result.current.isAttachmentHidden).toBe('function');
        expect(typeof result.current.updateHiddenAttachments).toBe('function');
        expect(typeof result.current.setCurrentAttachment).toBe('function');
        expect(typeof result.current.getCurrentAttachment).toBe('function');
    });

    it('should track hidden attachments', () => {
        const {result} = renderHook(() => useContext(AttachmentModalContext), {wrapper});

        expect(result.current.isAttachmentHidden('action1')).toBeFalsy();

        act(() => {
            result.current.updateHiddenAttachments('action1', true);
        });

        expect(result.current.isAttachmentHidden('action1')).toBe(true);
    });

    it('should store and retrieve current attachment', () => {
        const {result} = renderHook(() => useContext(AttachmentModalContext), {wrapper});

        expect(result.current.getCurrentAttachment()).toBeUndefined();

        const mockAttachment = {source: 'https://example.com/image.png', reportID: '123'};
        act(() => {
            result.current.setCurrentAttachment(mockAttachment);
        });

        expect(result.current.getCurrentAttachment()).toEqual(mockAttachment);
    });
});
tests/ui/components/ExpensifyCardContextProviderTest.tsx
import {renderHook, act} from '@testing-library/react-native';
import ExpensifyCardContextProvider, {useExpensifyCardState, useExpensifyCardActions} from '@pages/settings/Wallet/ExpensifyCardPage/ExpensifyCardContextProvider';

jest.mock('@hooks/useNonPersonalCardList', () => ({
    __esModule: true,
    default: jest.fn(() => ({})),
}));

const wrapper = ({children}: {children: React.ReactNode}) => (
    <ExpensifyCardContextProvider>{children}</ExpensifyCardContextProvider>
);

describe('ExpensifyCardContextProvider', () => {
    it('should provide initial empty state', () => {
        const {result} = renderHook(() => useExpensifyCardState(), {wrapper});

        expect(result.current.cardsDetails).toEqual({});
        expect(result.current.isCardDetailsLoading).toEqual({});
        expect(result.current.cardsDetailsErrors).toEqual({});
    });

    it('should provide setter actions', () => {
        const {result} = renderHook(() => useExpensifyCardActions(), {wrapper});

        expect(typeof result.current.setCardsDetails).toBe('function');
        expect(typeof result.current.setIsCardDetailsLoading).toBe('function');
        expect(typeof result.current.setCardsDetailsErrors).toBe('function');
    });

    it('should update card details via actions', () => {
        const {result} = renderHook(
            () => ({
                state: useExpensifyCardState(),
                actions: useExpensifyCardActions(),
            }),
            {wrapper},
        );

        act(() => {
            result.current.actions.setCardsDetails({1: {pan: '4111', cvv: '123', expiration: '12/25', pinSet: true}});
        });

        expect(result.current.state.cardsDetails).toHaveProperty('1');
    });

    it('should update loading state via actions', () => {
        const {result} = renderHook(
            () => ({
                state: useExpensifyCardState(),
                actions: useExpensifyCardActions(),
            }),
            {wrapper},
        );

        act(() => {
            result.current.actions.setIsCardDetailsLoading({1: true});
        });

        expect(result.current.state.isCardDetailsLoading).toEqual({1: true});
    });
});
tests/ui/components/TravelCVVContextProviderTest.tsx
import {renderHook, act} from '@testing-library/react-native';
import TravelCVVContextProvider, {useTravelCVVState, useTravelCVVActions} from '@pages/settings/Wallet/TravelCVVPage/TravelCVVContextProvider';

const wrapper = ({children}: {children: React.ReactNode}) => (
    <TravelCVVContextProvider>{children}</TravelCVVContextProvider>
);

describe('TravelCVVContextProvider', () => {
    it('should provide initial state with null CVV and no loading', () => {
        const {result} = renderHook(() => useTravelCVVState(), {wrapper});

        expect(result.current.cvv).toBeNull();
        expect(result.current.isLoading).toBe(false);
        expect(result.current.validateError).toEqual({});
    });

    it('should provide setter actions', () => {
        const {result} = renderHook(() => useTravelCVVActions(), {wrapper});

        expect(typeof result.current.setCvv).toBe('function');
        expect(typeof result.current.setIsLoading).toBe('function');
        expect(typeof result.current.setValidateError).toBe('function');
    });

    it('should update CVV via action', () => {
        const {result} = renderHook(
            () => ({
                state: useTravelCVVState(),
                actions: useTravelCVVActions(),
            }),
            {wrapper},
        );

        act(() => {
            result.current.actions.setCvv('123');
        });

        expect(result.current.state.cvv).toBe('123');
    });

    it('should update loading state via action', () => {
        const {result} = renderHook(
            () => ({
                state: useTravelCVVState(),
                actions: useTravelCVVActions(),
            }),
            {wrapper},
        );

        act(() => {
            result.current.actions.setIsLoading(true);
        });

        expect(result.current.state.isLoading).toBe(true);
    });

    it('should update validation errors via action', () => {
        const {result} = renderHook(
            () => ({
                state: useTravelCVVState(),
                actions: useTravelCVVActions(),
            }),
            {wrapper},
        );

        const errors = {cvv: 'Invalid CVV'};
        act(() => {
            result.current.actions.setValidateError(errors);
        });

        expect(result.current.state.validateError).toEqual(errors);
    });
});

⚠️ I can't push these directly because I'm not an assignee on this PR. To have me commit these files, add me to the PR assignees and retry the request.

@shubham1206agra
Copy link
Copy Markdown
Contributor Author

@MelvinBot I asked for manual test steps, not unit tests

@MelvinBot
Copy link
Copy Markdown
Contributor

Sorry about that! Here are manual test steps for each provider moved in this PR:

KeyboardDismissibleFlatListContextProvider

  1. Open any chat with many messages
  2. Tap the message input to open the keyboard
  3. Scroll through the message list while the keyboard is open
  4. Verify the list scrolls smoothly and the keyboard dismisses when scrolling down

KYCWallContextProvider

  1. Go to Settings > Wallet
  2. Tap "Enable Payments" (or attempt to send money if wallet isn't set up)
  3. Verify the KYC (identity verification) wall/modal appears correctly

ProductTrainingContextProvider

  1. Log in as a new user or clear dismissed tooltips
  2. Navigate through the app (e.g., open LHN, search, scan)
  3. Verify product training tooltips appear in the correct priority order and can be dismissed

SearchRouterContextProvider

  1. Press Cmd/Ctrl+K to open the search router
  2. Type a search query and verify results appear
  3. Close the search router with Escape
  4. Verify the search modal opens and closes correctly

SupportalPermissionDeniedModal

  1. This triggers when a Supportal action is denied — test by triggering a Supportal command without proper permissions
  2. Verify the permission denied modal appears with the correct command name and can be confirmed/dismissed

FullScreenContextProvider

  1. Open a chat with a video attachment
  2. Tap the video to enter fullscreen mode
  3. Exit fullscreen
  4. Verify fullscreen transitions work correctly and dimensions reset properly

PlaybackContextProvider

  1. Open a chat with a video attachment
  2. Play the video
  3. Navigate to another chat, then back
  4. Verify video playback state is preserved (or properly reset) when navigating

VideoPopoverMenuContextProvider

  1. Open a chat with a video attachment
  2. Play the video and long-press (or right-click) on it
  3. Verify the popover menu shows Download and Playback Speed options
  4. Change playback speed and verify it applies to the video

VolumeContextProvider

  1. Open a chat with a video attachment
  2. Play the video and adjust the volume slider
  3. Mute and unmute the video
  4. Verify volume persists when switching between videos

WideRHPContextProvider

  1. On a wide screen (desktop), open an expense report from the LHN
  2. Verify the Right Hand Panel (RHP) displays at the correct width
  3. Open a multi-transaction expense and verify it expands to super-wide RHP
  4. Resize the browser window and verify the RHP adjusts responsively

AttachmentModalContextProvider

  1. Open a chat with image attachments
  2. Tap an image to open the attachment modal
  3. Navigate between attachments in the modal
  4. Verify hidden attachments stay hidden and the correct attachment is displayed

ExpensifyCardContextProvider

  1. Go to Settings > Wallet > Expensify Card
  2. Tap "Reveal Details" on a card
  3. Verify card details (PAN, CVV, expiration) load and display correctly
  4. Verify loading states and error handling work properly

TravelCVVContextProvider

  1. Go to Settings > Wallet > Travel Card (if available)
  2. Request CVV reveal
  3. Verify CVV displays correctly and loading/error states work
  4. Navigate away and back — verify CVV is cleared (not persisted) for security

@huult
Copy link
Copy Markdown
Contributor

huult commented Apr 14, 2026

@shubham1206agra Could you please add video to both mWeb and the native app?

@huult The web recording is sufficient in this case. You can check if you want

@shubham1206agra I think mWeb and native app recordings are still needed to fully verify the behavior during testing or at least one of them.

@huult
Copy link
Copy Markdown
Contributor

huult commented Apr 14, 2026

#86441 (comment) @shubham1206agra Just checking, have you gone through all the features in these test steps? If not, please double-check to make sure everything works as expected after the provider move.

@shubham1206agra
Copy link
Copy Markdown
Contributor Author

@shubham1206agra Could you please add video to both mWeb and the native app?

@huult The web recording is sufficient in this case. You can check if you want

@shubham1206agra I think mWeb and native app recordings are still needed to fully verify the behavior during testing or at least one of them.

@huult I have already done that internally. Also this PR already went through QA already

@shubham1206agra
Copy link
Copy Markdown
Contributor Author

#86441 (comment) @shubham1206agra Just checking, have you gone through all the features in these test steps? If not, please double-check to make sure everything works as expected after the provider move.

@huult I actually went through all of them except TravelCVVContextProvider as I don't have Travel card

@huult
Copy link
Copy Markdown
Contributor

huult commented Apr 14, 2026

@shubham1206agra Could you please add video to both mWeb and the native app?

@huult The web recording is sufficient in this case. You can check if you want

@shubham1206agra I think mWeb and native app recordings are still needed to fully verify the behavior during testing or at least one of them.

@huult I have already done that internally. Also this PR already went through QA already

@shubham1206agra I’ll finish the review shortly.

Copy link
Copy Markdown
Contributor

@huult huult left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@roryabraham roryabraham merged commit 4448f26 into Expensify:main Apr 15, 2026
31 of 39 checks passed
@OSBotify
Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@github-actions
Copy link
Copy Markdown
Contributor

🚧 @roryabraham has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify
Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/roryabraham in version: 9.3.60-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

@MelvinBot
Copy link
Copy Markdown
Contributor

I reviewed the changes in this PR. It moves auth-only React context providers from App.tsx to AuthScreens.tsx and refactors SupportalPermissionDeniedModalProvider into a simpler SupportalPermissionDeniedModal component. This is purely an internal code reorganization with no user-facing changes.

No help site documentation changes are required.

@OSBotify
Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/mountiny in version: 9.3.60-22 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants