Repository: Expensify/App
Pull request #59896: Rewrite video player & its context logic
Author: login: JakubKorytko
Created: 2025-04-09T10:19:56Z | Merged: 2025-04-14T15:42:05Z

<!-- If necessary, assign reviewers that know the area or changes well. Feel free to tag any additional reviewers you see fit. -->

### Explanation of Change
<!-- Explain what your change does and how it addresses the linked issue -->

This PR rewrites the logic of the video player and its context, making video player work properly in the following cases (on both wide screens & narrow layouts):

- [X] Inside chats (inbox):

   - [X] Video can be played
   - [X] Video can be played in chat thread (even nested one)
   - [X]  Video can be played after reload/navigating to another route
   - [X] Video stops when changing routes / opening a thread with the video

- [X] Inside new report view:

   - [X] Video can be played
   - [X] Video can be played in chat thread (even nested one)
   - [X]  Video can be played after reload/navigating to another route
   - [X] Video stops when changing routes / opening a thread with the video

- [X] In RHP:

   - [X] Video can be played
   - [X] Video can be played in chat thread (even nested one)
   - [X] Video can be played after reload/navigating to another route
   - [X] Video stops when changing routes / opening a thread with the video


- [X] In chats via search:

   - [X] Video can be played
   - [X] Video can be played in chat thread (even nested one)
   - [X] Video can be played after reload/navigating to another route
   - [X] Video stops when changing routes / opening a thread with the video

### Fixed Issues
<!---
1. Please postfix `$` with a URL link to the GitHub issue this Pull Request is fixing. For example, `$ https://github.com/Expensify/App/issues/<issueID>`.
2. Please postfix  `PROPOSAL:` with a URL link to your GitHub comment, which contains the approved proposal (i.e. the proposal that was approved by Expensify).  For example, `PROPOSAL: https://github.com/Expensify/App/issues/<issueID>#issuecomment-1369752925`

Do NOT add the special GH keywords like `fixed` etc, we have our own process of managing the flow.
It MUST be an entire link to the github issue and your comment proposal ; otherwise, the linking and its automation will not work as expected.

Make sure this section looks similar to this (you can link multiple issues using the same formatting, just add a new line):

$ https://github.com/Expensify/App/issues/<issueID>
$ https://github.com/Expensify/App/issues/<issueID(comment)>

Do NOT only link the issue number like this: $ #<issueID>
--->
$ https://github.com/Expensify/App/issues/59774
$ https://github.com/Expensify/App/issues/57731
PROPOSAL: N/A


<!--- 
If you want to trigger adhoc build of hybrid app from specific Mobile-Expensify PR please link it like this:

MOBILE-EXPENSIFY: https://github.com/Expensify/Mobile-Expensify/pull/<PR-number>

--->

### Tests
<!---
Add a numbered list of manual tests you performed that validates your changes work on all platforms, and that there are no regressions present.
Add any additional test steps if test steps are unique to a particular platform.
Manual test steps should be written so that your reviewer can repeat and verify one or more expected outcomes in the development environment.

For example:
1. Click on the text input to bring it into focus
2. Upload an image via copy paste
3. Verify a modal appears displaying a preview of that image
--->

**[Chats (inbox)]**

1. Open any chat
1. Upload video
1. Play video
1. Verify it plays correctly
1. Open this video in a thread
1. Upload a video again in the thread
1. Verify that both videos play correctly.
1. Open the second video thread
1. Verify that both videos play correctly here as well.

**[Chats via search]**

1. Open reports
1. Select chats
1. Find uploaded video
1. Verify it plays properly

**[New report view]**

1. Open reports again
1. Open Expense Reports
1. Select any report with uploaded video
1. Verify it plays properly here as well

**[RHP]**

1. Open reports one more time
1. Select expenses
1. Open report with a video in RHP
1. Verify that video plays correctly there too

**After every check you should also:**

1. Refresh page
1. Verify that video still plays after refresh

### Offline tests
<!---
Add any relevant steps that validate your changes work as expected in a variety of network states e.g. "offline", "spotty connection", "slow internet", etc. Manual test steps should be written so that your reviewer and QA testers can repeat and verify one or more expected outcomes. If you are unsure how the behavior should work ask for advice in the `#expensify-open-source` Slack channel.
--->

N/A

### QA Steps
<!---
Add a numbered list of manual tests that can be performed by our QA engineers on the staging environment to validate that your changes work on all platforms, and that there are no regressions present.
Add any additional QA steps if test steps are unique to a particular platform.
Manual test steps should be written so that the QA engineer can repeat and verify one or more expected outcomes in the staging environment.

For example:
1. Click on the text input to bring it into focus
4. Upload an image via copy paste
5. Verify a modal appears displaying a preview of that image

It's acceptable to write "Same as tests" if the QA team is able to run the tests in the above "Tests" section.
--->

Same as tests

### PR Author Checklist
<!--
This is a checklist for PR authors. Please make sure to complete all tasks and check them off once you do, or else your PR will not be merged!
-->

- [x] I linked the correct issue in the `### Fixed Issues` section above
- [x] I wrote clear testing steps that cover the changes made in this PR
    - [x] I added steps for local testing in the `Tests` section
    - [x] I added steps for the expected offline behavior in the `Offline steps` section
    - [x] I added steps for Staging and/or Production testing in the `QA steps` section
    - [x] I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    - [x] 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)
    - [x] I tested this PR with a [High Traffic account](https://github.com/Expensify/App/blob/main/contributingGuides/CONTRIBUTING.md#high-traffic-accounts) against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
- [x] I included screenshots or videos for tests on [all platforms](https://github.com/Expensify/App/blob/main/contributingGuides/CONTRIBUTING.md#make-sure-you-can-test-on-all-platforms)
- [x] I ran the tests on **all platforms** & verified they passed on:
    - [x] Android: Native
    - [x] Android: mWeb Chrome
    - [x] iOS: Native
    - [x] iOS: mWeb Safari
    - [x] MacOS: Chrome / Safari
    - [x] MacOS: Desktop
- [x] 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)
- [x] I followed proper code patterns (see [Reviewing the code](https://github.com/Expensify/App/blob/main/contributingGuides/PR_REVIEW_GUIDELINES.md#reviewing-the-code))
    - [x] 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`)
    - [x] I verified that comments were added to code that is not self explanatory
    - [x] 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.
    - [x] I verified any copy / text shown in the product is localized by adding it to `src/languages/*` files and using the [translation method](https://github.com/Expensify/App/blob/4bd99402cebdf4d7394e0d1f260879ea238197eb/src/components/withLocalize.js#L60)
      - [x] If any non-english text was added/modified, I used [JaimeGPT](https://chatgpt.com/g/g-2dgOQl5VM-english-to-spanish-translator-aka-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:
    - [x] I verified all numbers, amounts, dates and phone numbers shown in the product are using the [localization methods](https://github.com/Expensify/App/blob/4bd99402cebdf4d7394e0d1f260879ea238197eb/src/components/withLocalize.js#L60-L68)
    - [x] 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)
    - [x] 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.
    - [x] I verified the JSDocs style guidelines (in [`STYLE.md`](https://github.com/Expensify/App/blob/main/contributingGuides/STYLE.md#jsdocs)) were followed
- [x] If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
- [x] I followed the guidelines as stated in the [Review Guidelines](https://github.com/Expensify/App/blob/main/contributingGuides/PR_REVIEW_GUIDELINES.md)
- [x] 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)
- [x] I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
- [x] 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
- [x] I verified that if a function's arguments changed that all usages have also been updated correctly
- [x] If any new file was added I verified that:
    - [x] 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
- [x] If a new CSS style is added I verified that:
    - [x] A similar style doesn't already exist
    - [x] The style can't be created with an existing [StyleUtils](https://github.com/Expensify/App/blob/main/src/styles/utils/index.ts) function (i.e. `StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)`)
- [x] 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.
- [x] 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)
- [x] 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.
- [x] 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.
- [x] 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:
    - [x] I verified that all the inputs inside a form are aligned with each other.
    - [x] I added `Design` label and/or tagged `@Expensify/design` so the design team can review the changes.
- [x] 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.
- [x] I added [unit tests](https://github.com/Expensify/App/blob/main/tests/README.md) for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
- [x] 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
<details>
<summary>Android: Native</summary>

<!-- add screenshots or videos here -->
https://github.com/user-attachments/assets/c235402a-fafe-4fce-9dfe-8272abc45001

https://github.com/user-attachments/assets/7299d587-fbf0-4af3-b9ad-21313bac97d0

</details>

<details>
<summary>Android: mWeb Chrome</summary>

<!-- add screenshots or videos here -->

</details>

<details>
<summary>iOS: Native</summary>

<!-- add screenshots or videos here -->

</details>

<details>
<summary>iOS: mWeb Safari</summary>

<!-- add screenshots or videos here -->

</details>

<details>
<summary>MacOS: Chrome / Safari</summary>

<!-- add screenshots or videos here -->
https://github.com/user-attachments/assets/b3af6664-67d4-4dac-a391-8363e056b209

https://github.com/user-attachments/assets/9f40eed3-8eef-4058-a9ab-169fda1601da

</details>

<details>
<summary>MacOS: Desktop</summary>

<!-- add screenshots or videos here -->

</details>



Diff:
diff --git a/src/components/AttachmentModal.tsx b/src/components/AttachmentModal.tsx
index 157f70a2cf52..886e636b3043 100644
--- a/src/components/AttachmentModal.tsx
+++ b/src/components/AttachmentModal.tsx
@@ -616,6 +616,7 @@ function AttachmentModal({
                                             isUsedInAttachmentModal
                                             transactionID={transaction?.transactionID}
                                             isUploaded={!isEmptyObject(report)}
+                                            reportID={!isEmptyObject(report) ? report.reportID : undefined}
                                         />
                                     </AttachmentCarouselPagerContext.Provider>
                                 )
diff --git a/src/components/Attachments/AttachmentView/index.tsx b/src/components/Attachments/AttachmentView/index.tsx
index 21df7d4b1f7c..e212e34b9595 100644
--- a/src/components/Attachments/AttachmentView/index.tsx
+++ b/src/components/Attachments/AttachmentView/index.tsx
@@ -11,6 +11,7 @@ import PerDiemEReceipt from '@components/PerDiemEReceipt';
 import ScrollView from '@components/ScrollView';
 import Text from '@components/Text';
 import {usePlaybackContext} from '@components/VideoPlayerContexts/PlaybackContext';
+import useFirstRenderRoute from '@hooks/useFirstRenderRoute';
 import useLocalize from '@hooks/useLocalize';
 import useNetwork from '@hooks/useNetwork';
 import useOnyx from '@hooks/useOnyx';
@@ -120,7 +121,7 @@ function AttachmentView({
 }: AttachmentViewProps) {
     const [transaction] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`);
     const {translate} = useLocalize();
-    const {updateCurrentlyPlayingURL} = usePlaybackContext();
+    const {updateCurrentURLAndReportID} = usePlaybackContext();
 
     const theme = useTheme();
     const {safeAreaPaddingBottomStyle} = useSafeAreaPaddings();
@@ -130,13 +131,15 @@ function AttachmentView({
     const [isHighResolution, setIsHighResolution] = useState<boolean>(false);
     const [hasPDFFailedToLoad, setHasPDFFailedToLoad] = useState(false);
     const isVideo = (typeof source === 'string' && Str.isVideo(source)) || (file?.name && Str.isVideo(file.name));
+    const firstRenderRoute = useFirstRenderRoute();
+    const isInFocusedModal = firstRenderRoute.isFocused && isFocused === undefined;
 
     useEffect(() => {
-        if (!isFocused && !(file && isUsedInAttachmentModal)) {
+        if (!isFocused && !isInFocusedModal && !(file && isUsedInAttachmentModal)) {
             return;
         }
-        updateCurrentlyPlayingURL(isVideo && typeof source === 'string' ? source : null);
-    }, [file, isFocused, isUsedInAttachmentModal, isVideo, source, updateCurrentlyPlayingURL]);
+        updateCurrentURLAndReportID(isVideo && typeof source === 'string' ? source : undefined, reportID);
+    }, [file, isFocused, isInFocusedModal, isUsedInAttachmentModal, isVideo, reportID, source, updateCurrentURLAndReportID]);
 
     const [imageError, setImageError] = useState(false);
 
diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/VideoRenderer.tsx b/src/components/HTMLEngineProvider/HTMLRenderers/VideoRenderer.tsx
index a446cbe406bc..74525489adb7 100644
--- a/src/components/HTMLEngineProvider/HTMLRenderers/VideoRenderer.tsx
+++ b/src/components/HTMLEngineProvider/HTMLRenderers/VideoRenderer.tsx
@@ -31,11 +31,11 @@ function VideoRenderer({tnode, key}: VideoRendererProps) {
         <ShowContextMenuContext.Consumer>
             {({report}) => (
                 <AttachmentContext.Consumer>
-                    {({accountID, type, hashKey}) => (
+                    {({accountID, type, hashKey, reportID}) => (
                         <VideoPlayerPreview
                             key={key}
                             videoUrl={sourceURL}
-                            reportID={report?.reportID}
+                            reportID={reportID ?? report?.reportID}
                             fileName={fileName}
                             thumbnailUrl={thumbnailUrl}
                             videoDimensions={{width, height}}
diff --git a/src/components/VideoPlayer/BaseVideoPlayer.tsx b/src/components/VideoPlayer/BaseVideoPlayer.tsx
index 241839b7a9ed..f553860a91d6 100644
--- a/src/components/VideoPlayer/BaseVideoPlayer.tsx
+++ b/src/components/VideoPlayer/BaseVideoPlayer.tsx
@@ -11,7 +11,6 @@ import AttachmentOfflineIndicator from '@components/AttachmentOfflineIndicator';
 import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator';
 import Hoverable from '@components/Hoverable';
 import PressableWithoutFeedback from '@components/Pressable/PressableWithoutFeedback';
-import {useSearchContext} from '@components/Search/SearchContext';
 import {useFullScreenContext} from '@components/VideoPlayerContexts/FullScreenContext';
 import {usePlaybackContext} from '@components/VideoPlayerContexts/PlaybackContext';
 import type {PlaybackSpeed} from '@components/VideoPlayerContexts/types';
@@ -65,10 +64,9 @@ function BaseVideoPlayer({
         originalParent,
         shareVideoPlayerElements,
         currentVideoPlayerRef,
-        updateCurrentlyPlayingURL,
+        updateCurrentURLAndReportID,
         videoResumeTryNumberRef,
         setCurrentlyPlayingURL,
-        currentlyPlayingURLReportID,
     } = usePlaybackContext();
     const {isFullScreenRef} = useFullScreenContext();
     const {isOffline} = useNetwork();
@@ -107,19 +105,18 @@ function BaseVideoPlayer({
     const {videoPopoverMenuPlayerRef, currentPlaybackSpeed, setCurrentPlaybackSpeed, setSource: setPopoverMenuSource} = useVideoPopoverMenuContext();
     const {source} = videoPopoverMenuPlayerRef.current?.props ?? {};
     const shouldUseNewRate = typeof source === 'number' || !source || source.uri !== sourceURL;
-    const {isOnSearch} = useSearchContext();
 
     const togglePlayCurrentVideo = useCallback(() => {
         setIsEnded(false);
         videoResumeTryNumberRef.current = 0;
         if (!isCurrentlyURLSet) {
-            updateCurrentlyPlayingURL(url);
+            updateCurrentURLAndReportID(url, reportID);
         } else if (isPlaying) {
             pauseVideo();
         } else {
             playVideo();
         }
-    }, [isCurrentlyURLSet, isPlaying, pauseVideo, playVideo, updateCurrentlyPlayingURL, url, videoResumeTryNumberRef]);
+    }, [isCurrentlyURLSet, isPlaying, pauseVideo, playVideo, reportID, updateCurrentURLAndReportID, url, videoResumeTryNumberRef]);
 
     const hideControl = useCallback(() => {
         if (isEnded) {
@@ -355,18 +352,15 @@ function BaseVideoPlayer({
 
     // update shared video elements
     useEffect(() => {
-        // in search page, we don't have active report id, so comparing reportID is not necessary
-        if (shouldUseSharedVideoElement || url !== currentlyPlayingURL || (reportID !== currentlyPlayingURLReportID && !isOnSearch)) {
-            return;
-        }
         // On mobile safari, we need to auto-play when sharing video element here
         shareVideoPlayerElements(
             videoPlayerRef.current,
             videoPlayerElementParentRef.current,
             videoPlayerElementRef.current,
             isUploading || isFullScreenRef.current || (!isReadyForDisplayRef.current && !isMobileSafari()),
+            {shouldUseSharedVideoElement, url, reportID},
         );
-    }, [currentlyPlayingURL, shouldUseSharedVideoElement, shareVideoPlayerElements, url, isUploading, isFullScreenRef, reportID, currentlyPlayingURLReportID, isOnSearch]);
+    }, [currentlyPlayingURL, shouldUseSharedVideoElement, shareVideoPlayerElements, url, isUploading, isFullScreenRef, reportID]);
 
     // Call bindFunctions() through the refs to avoid adding it to the dependency array of the DOM mutation effect, as doing so would change the DOM when the functions update.
     const bindFunctionsRef = useRef<(() => void) | null>(null);
@@ -413,14 +407,14 @@ function BaseVideoPlayer({
             }
             newParentRef.childNodes[0]?.remove();
         };
-    }, [currentVideoPlayerRef, currentlyPlayingURL, currentlyPlayingURLReportID, isFullScreenRef, originalParent, reportID, sharedElement, shouldUseSharedVideoElement, url]);
+    }, [currentVideoPlayerRef, currentlyPlayingURL, isFullScreenRef, originalParent, reportID, sharedElement, shouldUseSharedVideoElement, url]);
 
     useEffect(() => {
         if (!shouldPlay) {
             return;
         }
-        updateCurrentlyPlayingURL(url);
-    }, [shouldPlay, updateCurrentlyPlayingURL, url]);
+        updateCurrentURLAndReportID(url, reportID);
+    }, [reportID, shouldPlay, updateCurrentURLAndReportID, url]);
 
     useEffect(() => {
         videoPlayerRef.current?.setStatusAsync({isMuted: true});
@@ -531,6 +525,7 @@ function BaseVideoPlayer({
                                     togglePlayCurrentVideo={togglePlayCurrentVideo}
                                     controlsStatus={controlStatusState}
                                     showPopoverMenu={showPopoverMenu}
+                                    reportID={reportID}
                                 />
                             )}
                         </View>
diff --git a/src/components/VideoPlayer/VideoPlayerControls/ProgressBar/index.tsx b/src/components/VideoPlayer/VideoPlayerControls/ProgressBar/index.tsx
index 97e837658a3e..5c5dbd3e2f2f 100644
--- a/src/components/VideoPlayer/VideoPlayerControls/ProgressBar/index.tsx
+++ b/src/components/VideoPlayer/VideoPlayerControls/ProgressBar/index.tsx
@@ -23,13 +23,13 @@ function getProgress(currentPosition: number, maxPosition: number): number {
 
 function ProgressBar({duration, position, seekPosition}: ProgressBarProps) {
     const styles = useThemeStyles();
-    const {pauseVideo, playVideo, checkVideoPlaying} = usePlaybackContext();
+    const {pauseVideo, playVideo, checkIfVideoIsPlaying} = usePlaybackContext();
     const [sliderWidth, setSliderWidth] = useState(1);
     const [isSliderPressed, setIsSliderPressed] = useState(false);
     const progressWidth = useSharedValue(0);
     const wasVideoPlayingOnCheck = useSharedValue(false);
 
-    const onCheckVideoPlaying = (isPlaying: boolean) => {
+    const onCheckIfVideoIsPlaying = (isPlaying: boolean) => {
         wasVideoPlayingOnCheck.set(isPlaying);
     };
 
@@ -47,7 +47,7 @@ function ProgressBar({duration, position, seekPosition}: ProgressBarProps) {
         .runOnJS(true)
         .onBegin((event) => {
             setIsSliderPressed(true);
-            checkVideoPlaying(onCheckVideoPlaying);
+            checkIfVideoIsPlaying(onCheckIfVideoIsPlaying);
             pauseVideo();
             progressBarInteraction(event);
         })
diff --git a/src/components/VideoPlayer/VideoPlayerControls/index.tsx b/src/components/VideoPlayer/VideoPlayerControls/index.tsx
index 04cb69a96f8b..9ea5931729fa 100644
--- a/src/components/VideoPlayer/VideoPlayerControls/index.tsx
+++ b/src/components/VideoPlayer/VideoPlayerControls/index.tsx
@@ -46,6 +46,8 @@ type VideoPlayerControlsProps = {
     togglePlayCurrentVideo: (event?: GestureResponderEvent | KeyboardEvent) => void | Promise<void>;
 
     controlsStatus: ValueOf<typeof CONST.VIDEO_PLAYER.CONTROLS_STATUS>;
+
+    reportID: string | undefined;
 };
 
 function VideoPlayerControls({
@@ -59,10 +61,11 @@ function VideoPlayerControls({
     showPopoverMenu,
     togglePlayCurrentVideo,
     controlsStatus = CONST.VIDEO_PLAYER.CONTROLS_STATUS.SHOW,
+    reportID,
 }: VideoPlayerControlsProps) {
     const styles = useThemeStyles();
     const {translate} = useLocalize();
-    const {updateCurrentlyPlayingURL} = usePlaybackContext();
+    const {updateCurrentURLAndReportID} = usePlaybackContext();
     const {isFullScreenRef} = useFullScreenContext();
     const [shouldShowTime, setShouldShowTime] = useState(false);
     const iconSpacing = small ? styles.mr3 : styles.mr4;
@@ -74,9 +77,9 @@ function VideoPlayerControls({
     const enterFullScreenMode = useCallback(() => {
         // eslint-disable-next-line react-compiler/react-compiler
         isFullScreenRef.current = true;
-        updateCurrentlyPlayingURL(url);
+        updateCurrentURLAndReportID(url, reportID);
         videoPlayerRef.current?.presentFullscreenPlayer();
-    }, [isFullScreenRef, updateCurrentlyPlayingURL, url, videoPlayerRef]);
+    }, [isFullScreenRef, reportID, updateCurrentURLAndReportID, url, videoPlayerRef]);
 
     const seekPosition = useCallback(
         (newPosition: number) => {
diff --git a/src/components/VideoPlayerContexts/PlaybackContext.tsx b/src/components/VideoPlayerContexts/PlaybackContext.tsx
deleted file mode 100644
index 33076b5521a1..000000000000
--- a/src/components/VideoPlayerContexts/PlaybackContext.tsx
+++ /dev/null
@@ -1,250 +0,0 @@
-import type {NavigationState, Route} from '@react-navigation/native';
-import {findFocusedRoute} from '@react-navigation/native';
-import type {AVPlaybackStatus, AVPlaybackStatusToSet} from 'expo-av';
-import React, {useCallback, useContext, useEffect, useMemo, useRef, useState} from 'react';
-import type {View} from 'react-native';
-import type {OnyxEntry} from 'react-native-onyx';
-import type {VideoWithOnFullScreenUpdate} from '@components/VideoPlayer/types';
-import usePrevious from '@hooks/usePrevious';
-import getAttachmentDetails from '@libs/fileDownload/getAttachmentDetails';
-import isReportTopmostSplitNavigator from '@libs/Navigation/helpers/isReportTopmostSplitNavigator';
-import Navigation from '@libs/Navigation/Navigation';
-import {getAllReportActions, getReportActionHtml} from '@libs/ReportActionsUtils';
-import {getReportOrDraftReport, isChatThread} from '@libs/ReportUtils';
-import Visibility from '@libs/Visibility';
-import type {SearchFullscreenNavigatorParamList} from '@navigation/types';
-import ROUTES from '@src/ROUTES';
-import SCREENS from '@src/SCREENS';
-import type {Report} from '@src/types/onyx';
-import type ChildrenProps from '@src/types/utils/ChildrenProps';
-import type {PlaybackContext, StatusCallback} from './types';
-
-const Context = React.createContext<PlaybackContext | null>(null);
-
-type SearchRoute = Omit<Route<string>, 'key'> | undefined;
-type MoneyRequestReportState = {
-    params: SearchFullscreenNavigatorParamList[typeof SCREENS.SEARCH.MONEY_REQUEST_REPORT];
-} & SearchRoute;
-
-function isMoneyRequestReportRouteWithReportIDInParams(route: SearchRoute): route is MoneyRequestReportState {
-    return !!route && !!route.params && route.name === SCREENS.SEARCH.MONEY_REQUEST_REPORT && 'reportID' in route.params;
-}
-
-function findUrlInReportOrAncestorAttachments(currentReport: OnyxEntry<Report>, url: string | null): string | undefined {
-    const {parentReportID, reportID} = currentReport ?? {};
-
-    const reportActions = getAllReportActions(reportID);
-    const hasUrlInAttachments = Object.values(reportActions).some((action) => {
-        const {sourceURL, previewSourceURL} = getAttachmentDetails(getReportActionHtml(action));
-        return sourceURL === url || previewSourceURL === url;
-    });
-
-    if (hasUrlInAttachments) {
-        return reportID;
-    }
-
-    if (parentReportID) {
-        const parentReport = getReportOrDraftReport(parentReportID);
-        return findUrlInReportOrAncestorAttachments(parentReport, url);
-    }
-
-    return undefined;
-}
-
-function PlaybackContextProvider({children}: ChildrenProps) {
-    const [currentlyPlayingURL, setCurrentlyPlayingURL] = useState<string | null>(null);
-    const [currentlyPlayingURLReportID, setCurrentlyPlayingURLReportID] = useState<string | undefined>();
-    const [sharedElement, setSharedElement] = useState<View | HTMLDivElement | null>(null);
-    const [originalParent, setOriginalParent] = useState<View | HTMLDivElement | null>(null);
-    const currentVideoPlayerRef = useRef<VideoWithOnFullScreenUpdate | null>(null);
-    const [currentReportID, setCurrentReportID] = useState<string | undefined>();
-    const prevCurrentReportID = usePrevious(currentReportID);
-    const videoResumeTryNumberRef = useRef<number>(0);
-    const playVideoPromiseRef = useRef<Promise<AVPlaybackStatus>>();
-    const isPlayPendingRef = useRef(false);
-
-    const pauseVideo = useCallback(() => {
-        currentVideoPlayerRef.current?.setStatusAsync?.({shouldPlay: false});
-    }, [currentVideoPlayerRef]);
-
-    const stopVideo = useCallback(() => {
-        currentVideoPlayerRef.current?.setStatusAsync?.({shouldPlay: false, positionMillis: 0});
-    }, [currentVideoPlayerRef]);
-
-    const playVideo = useCallback(() => {
-        if (!Visibility.isVisible()) {
-            isPlayPendingRef.current = true;
-            return;
-        }
-        currentVideoPlayerRef.current?.getStatusAsync?.().then((status) => {
-            const newStatus: AVPlaybackStatusToSet = {shouldPlay: true};
-            if ('durationMillis' in status && status.durationMillis === status.positionMillis) {
-                newStatus.positionMillis = 0;
-            }
-            playVideoPromiseRef.current = currentVideoPlayerRef.current?.setStatusAsync(newStatus).catch((error: AVPlaybackStatus) => {
-                return error;
-            });
-        });
-    }, [currentVideoPlayerRef]);
-
-    const unloadVideo = useCallback(() => {
-        currentVideoPlayerRef.current?.unloadAsync?.();
-    }, [currentVideoPlayerRef]);
-
-    /**
-     * This function is used to update the currentReportID
-     * @param state root navigation state
-     */
-    const updateCurrentPlayingReportID = useCallback(
-        (state: NavigationState) => {
-            const focusedRoute = findFocusedRoute(state);
-            let {reportID} = getReportOrDraftReport(Navigation.getTopmostReportId()) ?? {};
-
-            // We need to handle a case where a report is selected via search and is therefore not a topmost report,
-            // but we still want to be able to play videos in it
-            if (isMoneyRequestReportRouteWithReportIDInParams(focusedRoute)) {
-                reportID = focusedRoute.params.reportID;
-            }
-
-            reportID = Navigation.getActiveRouteWithoutParams() === `/${ROUTES.ATTACHMENTS.route}` ? prevCurrentReportID : reportID;
-
-            setCurrentReportID(reportID);
-        },
-        [setCurrentReportID, prevCurrentReportID],
-    );
-
-    const updateCurrentlyPlayingURL = useCallback(
-        (url: string | null) => {
-            if (currentlyPlayingURL && url !== currentlyPlayingURL) {
-                pauseVideo();
-            }
-
-            // Used for /attachment route
-            const topMostReport = getReportOrDraftReport(Navigation.getTopmostReportId());
-            const reportIDFromUrlParams = new URLSearchParams(Navigation.getActiveRoute()).get('reportID') ?? undefined;
-            const attachmentReportID = Navigation.getActiveRouteWithoutParams() === `/${ROUTES.ATTACHMENTS.route}` ? prevCurrentReportID ?? reportIDFromUrlParams : undefined;
-            const reportIDWithUrl = isChatThread(topMostReport) ? findUrlInReportOrAncestorAttachments(topMostReport, url) : undefined;
-
-            // - if it is a chat thread, use chat thread ID or any ascentor ID since the video could have originally been sent on report many levels up
-            // - report ID in which we are currently, if it is not a chat thread
-            // - if it is an attachment route, then we take report ID from the URL params
-            const currentPlayReportID = [attachmentReportID, reportIDWithUrl, currentReportID].find((id) => id !== undefined);
-
-            setCurrentlyPlayingURLReportID(currentPlayReportID);
-            setCurrentlyPlayingURL(url);
-        },
-        [currentlyPlayingURL, currentReportID, prevCurrentReportID, pauseVideo],
-    );
-
-    const shareVideoPlayerElements = useCallback(
-        (ref: VideoWithOnFullScreenUpdate | null, parent: View | HTMLDivElement | null, child: View | HTMLDivElement | null, shouldNotAutoPlay: boolean) => {
-            currentVideoPlayerRef.current = ref;
-            setOriginalParent(parent);
-            setSharedElement(child);
-            // Prevents autoplay when uploading the attachment
-            if (!shouldNotAutoPlay) {
-                playVideo();
-            }
-        },
-        [playVideo],
-    );
-
-    const checkVideoPlaying = useCallback(
-        (statusCallback: StatusCallback) => {
-            currentVideoPlayerRef.current?.getStatusAsync?.().then((status) => {
-                statusCallback('isPlaying' in status && status.isPlaying);
-            });
-        },
-        [currentVideoPlayerRef],
-    );
-
-    const resetVideoPlayerData = useCallback(() => {
-        // Play video is an async operation and if we call stop video before the promise is completed,
-        // it will throw a console error. So, we'll wait until the promise is resolved before stopping the video.
-        (playVideoPromiseRef.current ?? Promise.resolve()).then(stopVideo).finally(() => {
-            videoResumeTryNumberRef.current = 0;
-            setCurrentlyPlayingURL(null);
-            setSharedElement(null);
-            setOriginalParent(null);
-            setCurrentlyPlayingURLReportID(undefined);
-            unloadVideo();
-            currentVideoPlayerRef.current = null;
-        });
-    }, [stopVideo, unloadVideo]);
-
-    useEffect(() => {
-        Navigation.isNavigationReady().then(() => {
-            // This logic ensures that resetVideoPlayerData is only called when currentReportID
-            // changes from one valid value (i.e., not an empty string or '-1') to another valid value.
-            // This prevents the video that plays when the app opens from being interrupted when currentReportID
-            // is initially empty or '-1', or when it changes from empty/'-1' to another value
-            // after the report screen in the central pane is mounted on the large screen.
-            if ((!currentReportID && isReportTopmostSplitNavigator()) || (!prevCurrentReportID && !isReportTopmostSplitNavigator()) || currentReportID === prevCurrentReportID) {
-                return;
-            }
-
-            // We call another setStatusAsync inside useLayoutEffect on the video component,
-            // so we add a delay here to prevent the error from appearing.
-            setTimeout(() => {
-                resetVideoPlayerData();
-            }, 0);
-        });
-    }, [currentReportID, prevCurrentReportID, resetVideoPlayerData]);
-
-    useEffect(() => {
-        const unsubscribeVisibilityListener = Visibility.onVisibilityChange(() => {
-            if (!Visibility.isVisible() || !isPlayPendingRef.current) {
-                return;
-            }
-            playVideo();
-            isPlayPendingRef.current = false;
-        });
-        return unsubscribeVisibilityListener;
-    }, [playVideo]);
-
-    const contextValue = useMemo(
-        () => ({
-            updateCurrentlyPlayingURL,
-            currentlyPlayingURL,
-            currentlyPlayingURLReportID,
-            originalParent,
-            sharedElement,
-            currentVideoPlayerRef,
-            shareVideoPlayerElements,
-            setCurrentlyPlayingURL,
-            playVideo,
-            pauseVideo,
-            checkVideoPlaying,
-            videoResumeTryNumberRef,
-            resetVideoPlayerData,
-            updateCurrentPlayingReportID,
-        }),
-        [
-            updateCurrentlyPlayingURL,
-            currentlyPlayingURL,
-            currentlyPlayingURLReportID,
-            originalParent,
-            sharedElement,
-            shareVideoPlayerElements,
-            playVideo,
-            pauseVideo,
-            checkVideoPlaying,
-            setCurrentlyPlayingURL,
-            resetVideoPlayerData,
-            updateCurrentPlayingReportID,
-        ],
-    );
-    return <Context.Provider value={contextValue}>{children}</Context.Provider>;
-}
-
-function usePlaybackContext() {
-    const playbackContext = useContext(Context);
-    if (!playbackContext) {
-        throw new Error('usePlaybackContext must be used within a PlaybackContextProvider');
-    }
-    return playbackContext;
-}
-
-PlaybackContextProvider.displayName = 'PlaybackContextProvider';
-
-export {Context as PlaybackContext, PlaybackContextProvider, usePlaybackContext};
diff --git a/src/components/VideoPlayerContexts/PlaybackContext/index.tsx b/src/components/VideoPlayerContexts/PlaybackContext/index.tsx
new file mode 100644
index 000000000000..74641f5579d1
--- /dev/null
+++ b/src/components/VideoPlayerContexts/PlaybackContext/index.tsx
@@ -0,0 +1,137 @@
+import React, {useCallback, useContext, useEffect, useMemo, useState} from 'react';
+import type {View} from 'react-native';
+import type {VideoWithOnFullScreenUpdate} from '@components/VideoPlayer/types';
+import {getReportOrDraftReport, isChatThread} from '@libs/ReportUtils';
+import Navigation from '@navigation/Navigation';
+import type ChildrenProps from '@src/types/utils/ChildrenProps';
+import type {ProtectedCurrentRouteReportID} from './playbackContextReportIDUtils';
+import {findUrlInReportOrAncestorAttachments, getCurrentRouteReportID, NO_REPORT_ID, NO_REPORT_ID_IN_PARAMS, normalizeReportID} from './playbackContextReportIDUtils';
+import type {OriginalParent, PlaybackContext, PlaybackContextValues} from './types';
+import usePlaybackContextVideoRefs from './usePlaybackContextVideoRefs';
+
+const Context = React.createContext<PlaybackContext | null>(null);
+
+function PlaybackContextProvider({children}: ChildrenProps) {
+    const [currentlyPlayingURL, setCurrentlyPlayingURL] = useState<PlaybackContextValues['currentlyPlayingURL']>(null);
+    const [sharedElement, setSharedElement] = useState<PlaybackContextValues['sharedElement']>(null);
+    const [originalParent, setOriginalParent] = useState<OriginalParent>(null);
+    const [currentRouteReportID, setCurrentRouteReportID] = useState<ProtectedCurrentRouteReportID>(NO_REPORT_ID);
+    const resetContextProperties = () => {
+        setSharedElement(null);
+        setOriginalParent(null);
+        setCurrentlyPlayingURL(null);
+        setCurrentRouteReportID(NO_REPORT_ID);
+    };
+
+    const video = usePlaybackContextVideoRefs(resetContextProperties);
+
+    const updateCurrentURLAndReportID: PlaybackContextValues['updateCurrentURLAndReportID'] = useCallback(
+        (url, reportID) => {
+            if (!url || !reportID) {
+                return;
+            }
+
+            if (currentlyPlayingURL && url !== currentlyPlayingURL) {
+                video.pause();
+            }
+
+            const report = getReportOrDraftReport(reportID);
+            const isReportAChatThread = isChatThread(report);
+            let reportIDtoSet;
+            if (isReportAChatThread) {
+                reportIDtoSet = findUrlInReportOrAncestorAttachments(report, url) ?? NO_REPORT_ID;
+            } else {
+                reportIDtoSet = reportID;
+            }
+
+            const routeReportID = getCurrentRouteReportID(url);
+
+            if (reportIDtoSet === routeReportID || routeReportID === NO_REPORT_ID_IN_PARAMS) {
+                setCurrentRouteReportID(reportIDtoSet);
+            }
+
+            setCurrentlyPlayingURL(url);
+        },
+        [currentlyPlayingURL, video],
+    );
+
+    const shareVideoPlayerElements: PlaybackContextValues['shareVideoPlayerElements'] = useCallback(
+        (
+            ref: VideoWithOnFullScreenUpdate | null,
+            parent: View | HTMLDivElement | null,
+            child: View | HTMLDivElement | null,
+            shouldNotAutoPlay: boolean,
+            {shouldUseSharedVideoElement, url, reportID},
+        ) => {
+            if (shouldUseSharedVideoElement || url !== currentlyPlayingURL || reportID !== currentRouteReportID) {
+                return;
+            }
+
+            video.updateRef(ref);
+            setOriginalParent(parent);
+            setSharedElement(child);
+            // Prevents autoplay when uploading the attachment
+            if (!shouldNotAutoPlay) {
+                video.play();
+            }
+        },
+        [currentRouteReportID, currentlyPlayingURL, video],
+    );
+
+    useEffect(() => {
+        Navigation.isNavigationReady().then(() => {
+            // This logic ensures that resetVideoPlayerData is only called when currentReportID
+            // changes from one valid value (i.e., not an empty string or '-1') to another valid value.
+            // This prevents the video that plays when the app opens from being interrupted when currentReportID
+            // is initially empty or '-1', or when it changes from empty/'-1' to another value
+            // after the report screen in the central pane is mounted on the large screen.
+            const routeReportID = currentlyPlayingURL ? getCurrentRouteReportID(currentlyPlayingURL) : undefined;
+
+            const isSameReportID = routeReportID === currentRouteReportID || routeReportID === NO_REPORT_ID;
+            const isOnRouteWithoutReportID = !!currentlyPlayingURL && getCurrentRouteReportID(currentlyPlayingURL) === NO_REPORT_ID_IN_PARAMS;
+
+            if (isSameReportID || isOnRouteWithoutReportID) {
+                return;
+            }
+
+            // We call another setStatusAsync inside useLayoutEffect on the video component,
+            // so we add a delay here to prevent the error from appearing.
+            setTimeout(() => {
+                video.resetPlayerData();
+            }, 0);
+        });
+    }, [currentRouteReportID, currentlyPlayingURL, video, video.resetPlayerData]);
+
+    const contextValue: PlaybackContext = useMemo(
+        () => ({
+            updateCurrentURLAndReportID,
+            currentlyPlayingURL,
+            currentRouteReportID: normalizeReportID(currentRouteReportID),
+            originalParent,
+            sharedElement,
+            shareVideoPlayerElements,
+            setCurrentlyPlayingURL,
+            currentVideoPlayerRef: video.ref,
+            playVideo: video.play,
+            pauseVideo: video.pause,
+            checkIfVideoIsPlaying: video.isPlaying,
+            videoResumeTryNumberRef: video.resumeTryNumberRef,
+            resetVideoPlayerData: video.resetPlayerData,
+        }),
+        [updateCurrentURLAndReportID, currentlyPlayingURL, currentRouteReportID, originalParent, sharedElement, video, shareVideoPlayerElements],
+    );
+
+    return <Context.Provider value={contextValue}>{children}</Context.Provider>;
+}
+
+function usePlaybackContext() {
+    const playbackContext = useContext(Context);
+    if (!playbackContext) {
+        throw new Error('usePlaybackContext must be used within a PlaybackContextProvider');
+    }
+    return playbackContext;
+}
+
+PlaybackContextProvider.displayName = 'PlaybackContextProvider';
+
+export {Context as PlaybackContext, PlaybackContextProvider, usePlaybackContext};
diff --git a/src/components/VideoPlayerContexts/PlaybackContext/playbackContextReportIDUtils.ts b/src/components/VideoPlayerContexts/PlaybackContext/playbackContextReportIDUtils.ts
new file mode 100644
index 000000000000..5d85d039263f
--- /dev/null
+++ b/src/components/VideoPlayerContexts/PlaybackContext/playbackContextReportIDUtils.ts
@@ -0,0 +1,78 @@
+import {findFocusedRoute} from '@react-navigation/native';
+import type {Route} from '@react-navigation/native';
+import type {OnyxEntry} from 'react-native-onyx';
+import getAttachmentDetails from '@libs/fileDownload/getAttachmentDetails';
+import {getAllReportActions, getReportActionHtml} from '@libs/ReportActionsUtils';
+import {getReportOrDraftReport, isChatThread} from '@libs/ReportUtils';
+import getStateFromPath from '@navigation/helpers/getStateFromPath';
+import Navigation from '@navigation/Navigation';
+import type {ReportDetailsNavigatorParamList} from '@navigation/types';
+import type {Route as ActiveRoute} from '@src/ROUTES';
+import SCREENS from '@src/SCREENS';
+import type {Report} from '@src/types/onyx';
+
+/* NO_REPORT_ID & NO_REPORT_ID_IN_PARAMS are used to differentiate if the ReportID is simply missing or if it is just missing from the route params.
+ * Since both are a unique symbol they should not be used outside of these context files to avoid having to always import them.
+ * normalizeReportID is used to return the context value outside, so from a calling hook perspective these symbols doesn't matter at all */
+const NO_REPORT_ID: unique symbol = Symbol(undefined);
+const NO_REPORT_ID_IN_PARAMS: unique symbol = Symbol(undefined);
+type ProtectedCurrentRouteReportID = string | typeof NO_REPORT_ID_IN_PARAMS | typeof NO_REPORT_ID;
+
+const normalizeReportID = (reportID: ProtectedCurrentRouteReportID) => {
+    if (reportID === NO_REPORT_ID_IN_PARAMS || reportID === NO_REPORT_ID) {
+        return undefined;
+    }
+
+    return reportID;
+};
+
+type SearchRoute = Omit<Route<string>, 'key'> | undefined;
+type RouteWithReportIDInParams<T> = T & {params: ReportDetailsNavigatorParamList[typeof SCREENS.REPORT_DETAILS.ROOT]};
+
+const getCurrentRouteReportID: (url: string) => string | ProtectedCurrentRouteReportID = (url): string | typeof NO_REPORT_ID_IN_PARAMS | typeof NO_REPORT_ID => {
+    const route = Navigation.getActiveRouteWithoutParams() as ActiveRoute;
+    const focusedRoute = findFocusedRoute(getStateFromPath(route));
+    const reportIDFromUrlParams = new URLSearchParams(Navigation.getActiveRoute()).get('reportID');
+
+    const focusedRouteReportID = hasReportIdInRouteParams(focusedRoute) ? focusedRoute.params.reportID : reportIDFromUrlParams;
+
+    if (!focusedRouteReportID) {
+        return NO_REPORT_ID_IN_PARAMS;
+    }
+
+    const report = getReportOrDraftReport(focusedRouteReportID);
+    const isFocusedRouteAChatThread = isChatThread(report);
+    const firstReportThatHasURLInAttachments = findUrlInReportOrAncestorAttachments(report, url);
+
+    return isFocusedRouteAChatThread ? firstReportThatHasURLInAttachments : focusedRouteReportID;
+};
+
+const screensWithReportID = [SCREENS.SEARCH.REPORT_RHP, SCREENS.REPORT, SCREENS.SEARCH.MONEY_REQUEST_REPORT, SCREENS.ATTACHMENTS];
+
+function hasReportIdInRouteParams(route: SearchRoute): route is RouteWithReportIDInParams<SearchRoute> {
+    return !!route && !!route.params && !!screensWithReportID.find((screen) => screen === route.name) && 'reportID' in route.params;
+}
+
+function findUrlInReportOrAncestorAttachments(currentReport: OnyxEntry<Report>, url: string | null): string | typeof NO_REPORT_ID {
+    const {parentReportID, reportID} = currentReport ?? {};
+
+    const reportActions = getAllReportActions(reportID);
+    const hasUrlInAttachments = Object.values(reportActions).some((action) => {
+        const {sourceURL, previewSourceURL} = getAttachmentDetails(getReportActionHtml(action));
+        return sourceURL === url || previewSourceURL === url;
+    });
+
+    if (hasUrlInAttachments) {
+        return reportID ?? NO_REPORT_ID;
+    }
+
+    if (parentReportID) {
+        const parentReport = getReportOrDraftReport(parentReportID);
+        return findUrlInReportOrAncestorAttachments(parentReport, url);
+    }
+
+    return NO_REPORT_ID;
+}
+
+export {NO_REPORT_ID, NO_REPORT_ID_IN_PARAMS, getCurrentRouteReportID, normalizeReportID, findUrlInReportOrAncestorAttachments};
+export type {ProtectedCurrentRouteReportID};
diff --git a/src/components/VideoPlayerContexts/PlaybackContext/types.ts b/src/components/VideoPlayerContexts/PlaybackContext/types.ts
new file mode 100644
index 000000000000..437b6ee5020b
--- /dev/null
+++ b/src/components/VideoPlayerContexts/PlaybackContext/types.ts
@@ -0,0 +1,53 @@
+import type {AVPlaybackStatus} from 'expo-av';
+import type {MutableRefObject} from 'react';
+import type {View} from 'react-native';
+import type {VideoWithOnFullScreenUpdate} from '@components/VideoPlayer/types';
+
+type StatusCallback = (isPlaying: boolean) => void;
+type OriginalParent = View | HTMLDivElement | null;
+type UnloadVideo = () => void;
+type StopVideo = () => void;
+type PlayVideoPromiseRef = MutableRefObject<Promise<AVPlaybackStatus> | undefined>;
+
+type VideoElementData = {
+    shouldUseSharedVideoElement: boolean;
+    url: string;
+    reportID: string | undefined;
+};
+
+type PlaybackContextValues = {
+    updateCurrentURLAndReportID: (url: string | undefined, reportID: string | undefined) => void;
+    currentlyPlayingURL: string | null;
+    currentRouteReportID: string | undefined;
+    originalParent: View | HTMLDivElement | null;
+    sharedElement: View | HTMLDivElement | null;
+    shareVideoPlayerElements: (
+        ref: VideoWithOnFullScreenUpdate | null,
+        parent: View | HTMLDivElement | null,
+        child: View | HTMLDivElement | null,
+        isUploading: boolean,
+        videoElementData: VideoElementData,
+    ) => void;
+    setCurrentlyPlayingURL: React.Dispatch<React.SetStateAction<string | null>>;
+};
+
+type PlaybackContextVideoRefs = {
+    resetPlayerData: () => void;
+    play: () => void;
+    pause: () => void;
+    isPlaying: (statusCallback: StatusCallback) => void;
+    resumeTryNumberRef: MutableRefObject<number>;
+    ref: MutableRefObject<VideoWithOnFullScreenUpdate | null>;
+    updateRef: (ref: VideoWithOnFullScreenUpdate | null) => void;
+};
+
+type PlaybackContext = PlaybackContextValues & {
+    resetVideoPlayerData: PlaybackContextVideoRefs['resetPlayerData'];
+    playVideo: PlaybackContextVideoRefs['play'];
+    pauseVideo: PlaybackContextVideoRefs['pause'];
+    checkIfVideoIsPlaying: PlaybackContextVideoRefs['isPlaying'];
+    videoResumeTryNumberRef: PlaybackContextVideoRefs['resumeTryNumberRef'];
+    currentVideoPlayerRef: PlaybackContextVideoRefs['ref'];
+};
+
+export type {StatusCallback, PlaybackContextValues, OriginalParent, UnloadVideo, StopVideo, PlayVideoPromiseRef, PlaybackContextVideoRefs, PlaybackContext};
diff --git a/src/components/VideoPlayerContexts/PlaybackContext/usePlaybackContextVideoRefs.ts b/src/components/VideoPlayerContexts/PlaybackContext/usePlaybackContextVideoRefs.ts
new file mode 100644
index 000000000000..b072997579ab
--- /dev/null
+++ b/src/components/VideoPlayerContexts/PlaybackContext/usePlaybackContextVideoRefs.ts
@@ -0,0 +1,88 @@
+import type {AVPlaybackStatus, AVPlaybackStatusToSet} from 'expo-av';
+import {useCallback, useEffect, useMemo, useRef} from 'react';
+import Visibility from '@libs/Visibility';
+import type {PlaybackContextVideoRefs, PlayVideoPromiseRef, StopVideo, UnloadVideo} from './types';
+
+function usePlaybackContextVideoRefs(resetCallback: () => void) {
+    const currentVideoPlayerRef: PlaybackContextVideoRefs['ref'] = useRef(null);
+    const videoResumeTryNumberRef: PlaybackContextVideoRefs['resumeTryNumberRef'] = useRef(0);
+    const playVideoPromiseRef: PlayVideoPromiseRef = useRef();
+    const isPlayPendingRef = useRef(false);
+
+    const pauseVideo: PlaybackContextVideoRefs['pause'] = useCallback(() => {
+        currentVideoPlayerRef.current?.setStatusAsync?.({shouldPlay: false});
+    }, [currentVideoPlayerRef]);
+
+    const stopVideo: StopVideo = useCallback(() => {
+        currentVideoPlayerRef.current?.setStatusAsync?.({shouldPlay: false, positionMillis: 0});
+    }, [currentVideoPlayerRef]);
+
+    const playVideo: PlaybackContextVideoRefs['play'] = useCallback(() => {
+        if (!Visibility.isVisible()) {
+            isPlayPendingRef.current = true;
+            return;
+        }
+        currentVideoPlayerRef.current?.getStatusAsync?.().then((status) => {
+            const newStatus: AVPlaybackStatusToSet = {shouldPlay: true};
+            if ('durationMillis' in status && status.durationMillis === status.positionMillis) {
+                newStatus.positionMillis = 0;
+            }
+            playVideoPromiseRef.current = currentVideoPlayerRef.current?.setStatusAsync(newStatus).catch((error: AVPlaybackStatus) => {
+                return error;
+            });
+        });
+    }, [currentVideoPlayerRef]);
+
+    const unloadVideo: UnloadVideo = useCallback(() => {
+        currentVideoPlayerRef.current?.unloadAsync?.();
+    }, [currentVideoPlayerRef]);
+
+    const checkIfVideoIsPlaying: PlaybackContextVideoRefs['isPlaying'] = useCallback(
+        (statusCallback) => {
+            currentVideoPlayerRef.current?.getStatusAsync?.().then((status) => {
+                statusCallback('isPlaying' in status && status.isPlaying);
+            });
+        },
+        [currentVideoPlayerRef],
+    );
+
+    const resetVideoPlayerData: PlaybackContextVideoRefs['resetPlayerData'] = useCallback(() => {
+        // Play video is an async operation and if we call stop video before the promise is completed,
+        // it will throw a console error. So, we'll wait until the promise is resolved before stopping the video.
+        (playVideoPromiseRef.current ?? Promise.resolve()).then(stopVideo).finally(() => {
+            videoResumeTryNumberRef.current = 0;
+            resetCallback();
+            unloadVideo();
+            currentVideoPlayerRef.current = null;
+        });
+    }, [resetCallback, stopVideo, unloadVideo]);
+
+    useEffect(() => {
+        return Visibility.onVisibilityChange(() => {
+            if (!Visibility.isVisible() || !isPlayPendingRef.current) {
+                return;
+            }
+            playVideo();
+            isPlayPendingRef.current = false;
+        });
+    }, [playVideo]);
+
+    const updateCurrentVideoPlayerRef: PlaybackContextVideoRefs['updateRef'] = (ref) => {
+        currentVideoPlayerRef.current = ref;
+    };
+
+    return useMemo(
+        (): PlaybackContextVideoRefs => ({
+            resetPlayerData: resetVideoPlayerData,
+            isPlaying: checkIfVideoIsPlaying,
+            pause: pauseVideo,
+            play: playVideo,
+            ref: currentVideoPlayerRef,
+            resumeTryNumberRef: videoResumeTryNumberRef,
+            updateRef: updateCurrentVideoPlayerRef,
+        }),
+        [checkIfVideoIsPlaying, pauseVideo, playVideo, resetVideoPlayerData],
+    );
+}
+
+export default usePlaybackContextVideoRefs;
diff --git a/src/components/VideoPlayerContexts/types.ts b/src/components/VideoPlayerContexts/types.ts
index 0037c699e354..c46ecd534d5c 100644
--- a/src/components/VideoPlayerContexts/types.ts
+++ b/src/components/VideoPlayerContexts/types.ts
@@ -1,6 +1,4 @@
-import type {NavigationState} from '@react-navigation/native';
 import type {MutableRefObject} from 'react';
-import type {View} from 'react-native';
 import type {SharedValue} from 'react-native-reanimated';
 import type {TupleToUnion} from 'type-fest';
 import type {PopoverMenuItem} from '@components/PopoverMenu';
@@ -8,23 +6,6 @@ import type {VideoWithOnFullScreenUpdate} from '@components/VideoPlayer/types';
 import type CONST from '@src/CONST';
 import type {ResponsiveLayoutProperties} from './FullScreenContext';
 
-type PlaybackContext = {
-    updateCurrentlyPlayingURL: (url: string | null) => void;
-    currentlyPlayingURL: string | null;
-    currentlyPlayingURLReportID: string | undefined;
-    originalParent: View | HTMLDivElement | null;
-    sharedElement: View | HTMLDivElement | null;
-    videoResumeTryNumberRef: MutableRefObject<number>;
-    currentVideoPlayerRef: MutableRefObject<VideoWithOnFullScreenUpdate | null>;
-    shareVideoPlayerElements: (ref: VideoWithOnFullScreenUpdate | null, parent: View | HTMLDivElement | null, child: View | HTMLDivElement | null, isUploading: boolean) => void;
-    playVideo: () => void;
-    pauseVideo: () => void;
-    checkVideoPlaying: (statusCallback: StatusCallback) => void;
-    setCurrentlyPlayingURL: React.Dispatch<React.SetStateAction<string | null>>;
-    resetVideoPlayerData: () => void;
-    updateCurrentPlayingReportID: (state: NavigationState) => void;
-};
-
 type VolumeContext = {
     updateVolume: (newVolume: number) => void;
     volume: SharedValue<number>;
@@ -48,8 +29,6 @@ type FullScreenContext = {
     unlockWindowDimensions: () => void;
 };
 
-type StatusCallback = (isPlaying: boolean) => void;
-
 type PlaybackSpeed = TupleToUnion<typeof CONST.VIDEO_PLAYER.PLAYBACK_SPEEDS>;
 
-export type {PlaybackContext, VolumeContext, VideoPopoverMenuContext, FullScreenContext, StatusCallback, PlaybackSpeed};
+export type {VolumeContext, VideoPopoverMenuContext, FullScreenContext, PlaybackSpeed};
diff --git a/src/components/VideoPlayerPreview/index.tsx b/src/components/VideoPlayerPreview/index.tsx
index 4e077523fe53..3f63dcb62759 100644
--- a/src/components/VideoPlayerPreview/index.tsx
+++ b/src/components/VideoPlayerPreview/index.tsx
@@ -50,14 +50,17 @@ type VideoPlayerPreviewProps = {
 function VideoPlayerPreview({videoUrl, thumbnailUrl, reportID, fileName, videoDimensions, videoDuration, onShowModalPress, isDeleted}: VideoPlayerPreviewProps) {
     const styles = useThemeStyles();
     const {translate} = useLocalize();
-    const {currentlyPlayingURL, currentlyPlayingURLReportID, updateCurrentlyPlayingURL} = usePlaybackContext();
-    const {shouldUseNarrowLayout} = useResponsiveLayout();
+    const {currentlyPlayingURL, currentRouteReportID, updateCurrentURLAndReportID} = usePlaybackContext();
+
+    /* This needs to be isSmallScreenWidth because we want to be able to play video in chat (not in attachment modal) when preview is inside an RHP */
+    // eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth
+    const {isSmallScreenWidth} = useResponsiveLayout();
+
     const [isThumbnail, setIsThumbnail] = useState(true);
     const [measuredDimensions, setMeasuredDimensions] = useState(videoDimensions);
     const {thumbnailDimensionsStyles} = useThumbnailDimensions(measuredDimensions.width, measuredDimensions.height);
     const {isOnSearch} = useSearchContext();
     const navigation = useNavigation();
-
     // We want to play the video only when the user is on the page where it was rendered
     const firstRenderRoute = useFirstRenderRoute([`/${ROUTES.ATTACHMENTS.route}`]);
 
@@ -68,8 +71,8 @@ function VideoPlayerPreview({videoUrl, thumbnailUrl, reportID, fileName, videoDi
     };
 
     const handleOnPress = () => {
-        updateCurrentlyPlayingURL(videoUrl);
-        if (shouldUseNarrowLayout) {
+        updateCurrentURLAndReportID(videoUrl, reportID);
+        if (isSmallScreenWidth) {
             onShowModalPress();
         }
     };
@@ -79,15 +82,15 @@ function VideoPlayerPreview({videoUrl, thumbnailUrl, reportID, fileName, videoDi
     }, [navigation, firstRenderRoute]);
 
     useEffect(() => {
-        if (videoUrl !== currentlyPlayingURL || (reportID !== currentlyPlayingURLReportID && !isOnSearch) || !firstRenderRoute.isFocused) {
+        if (videoUrl !== currentlyPlayingURL || reportID !== currentRouteReportID || !firstRenderRoute.isFocused) {
             return;
         }
         setIsThumbnail(false);
-    }, [currentlyPlayingURL, currentlyPlayingURLReportID, updateCurrentlyPlayingURL, videoUrl, reportID, firstRenderRoute, isOnSearch]);
+    }, [currentlyPlayingURL, currentRouteReportID, updateCurrentURLAndReportID, videoUrl, reportID, firstRenderRoute, isOnSearch]);
 
     return (
         <View style={[styles.webViewStyles.tagStyles.video, thumbnailDimensionsStyles]}>
-            {shouldUseNarrowLayout || isThumbnail || isDeleted ? (
+            {isSmallScreenWidth || isThumbnail || isDeleted ? (
                 <VideoPlayerThumbnail
                     thumbnailUrl={thumbnailUrl}
                     onPress={handleOnPress}
diff --git a/src/hooks/useFirstRenderRoute.ts b/src/hooks/useFirstRenderRoute.ts
index f64629f65948..b4766ebbeb92 100644
--- a/src/hooks/useFirstRenderRoute.ts
+++ b/src/hooks/useFirstRenderRoute.ts
@@ -5,7 +5,9 @@ function useFirstRenderRoute(focusExceptionRoutes?: string[]) {
     const initialRoute = useRef<string | null>(null);
 
     useEffect(() => {
-        initialRoute.current = Navigation.getActiveRouteWithoutParams();
+        Navigation.isNavigationReady().then(() => {
+            initialRoute.current = Navigation.getActiveRouteWithoutParams();
+        });
     }, []);
 
     return {
diff --git a/src/libs/Navigation/NavigationRoot.tsx b/src/libs/Navigation/NavigationRoot.tsx
index 8a720695260e..079cdfaca259 100644
--- a/src/libs/Navigation/NavigationRoot.tsx
+++ b/src/libs/Navigation/NavigationRoot.tsx
@@ -3,7 +3,6 @@ import type {NavigationState} from '@react-navigation/native';
 import React, {useContext, useEffect, useMemo, useRef} from 'react';
 import {useOnyx} from 'react-native-onyx';
 import {ScrollOffsetContext} from '@components/ScrollOffsetContextProvider';
-import {usePlaybackContext} from '@components/VideoPlayerContexts/PlaybackContext';
 import useCurrentReportID from '@hooks/useCurrentReportID';
 import usePrevious from '@hooks/usePrevious';
 import useResponsiveLayout from '@hooks/useResponsiveLayout';
@@ -92,7 +91,6 @@ function NavigationRoot({authenticated, lastVisitedPath, initialUrl, onReady}: N
     const {cleanStaleScrollOffsets} = useContext(ScrollOffsetContext);
 
     const currentReportIDValue = useCurrentReportID();
-    const {updateCurrentPlayingReportID} = usePlaybackContext();
     const {shouldUseNarrowLayout} = useResponsiveLayout();
     const [user] = useOnyx(ONYXKEYS.USER);
     const isPrivateDomain = Session.isUserOnPrivateDomain();
@@ -222,7 +220,6 @@ function NavigationRoot({authenticated, lastVisitedPath, initialUrl, onReady}: N
         // Performance optimization to avoid context consumers to delay first render
         setTimeout(() => {
             currentReportIDValue?.updateCurrentReportID(state);
-            updateCurrentPlayingReportID(state);
         }, 0);
         parseAndLogRoute(state);
 


Reviews:
user: login: DylanDylann
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-10T08:22:19Z
user: login: JakubKorytko
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-10T08:22:46Z
user: login: Skalakid
body: Left some small comments, I really like how you broke this context into smaller parts. Good job! 
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-11T16:09:18Z
user: login: JakubKorytko
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-14T08:00:44Z
user: login: DylanDylann
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-04-14T15:02:02Z
user: login: mountiny
body: Only one NAB, changes look good to me, thank you for refactoring this
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-04-14T15:39:55Z

Review comments:
diff_hunk: @@ -55,7 +55,7 @@ function ChatListItem<TItem extends ListItem>({
 
     const contextValue = {
         anchor: null,
-        report: undefined,
+        report: reportActionItem,
path: src/components/SelectionList/ChatListItem.tsx
user: login: DylanDylann
body: Why do we change this line? It is confused to me because we are assigning a report action to report
created_at: 2025-04-10T08:22:16Z
author_association: CONTRIBUTOR
diff_hunk: @@ -55,7 +55,7 @@ function ChatListItem<TItem extends ListItem>({
 
     const contextValue = {
         anchor: null,
-        report: undefined,
+        report: reportActionItem,
path: src/components/SelectionList/ChatListItem.tsx
user: login: JakubKorytko
body: No longer a thing, deleted after merge.
created_at: 2025-04-10T08:22:45Z
author_association: CONTRIBUTOR
diff_hunk: @@ -31,11 +31,11 @@ function VideoRenderer({tnode, key}: VideoRendererProps) {
         <ShowContextMenuContext.Consumer>
             {({report}) => (
                 <AttachmentContext.Consumer>
-                    {({accountID, type, hashKey}) => (
+                    {({accountID, type, hashKey, reportID}) => (
                         <VideoPlayerPreview
                             key={key}
                             videoUrl={sourceURL}
-                            reportID={report?.reportID}
+                            reportID={reportID ?? report?.reportID}
path: src/components/HTMLEngineProvider/HTMLRenderers/VideoRenderer.tsx
user: login: Skalakid
body: Can `reportID` and `report?.reportID` have different values?
created_at: 2025-04-11T14:46:40Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,133 @@
+import React, {useCallback, useContext, useEffect, useMemo, useState} from 'react';
+import type {View} from 'react-native';
+import type {VideoWithOnFullScreenUpdate} from '@components/VideoPlayer/types';
+import {getReportOrDraftReport, isChatThread} from '@libs/ReportUtils';
+import Navigation from '@navigation/Navigation';
+import type ChildrenProps from '@src/types/utils/ChildrenProps';
+import type {ProtectedCurrentRouteReportID} from './playbackContextReportIDUtils';
+import {findUrlInReportOrAncestorAttachments, getCurrentRouteReportID, NO_REPORT_ID, NO_REPORT_ID_IN_PARAMS, normalizeReportID} from './playbackContextReportIDUtils';
+import type {OriginalParent, PlaybackContext} from './types';
+import usePlaybackContextVideoRefs from './usePlaybackContextVideoRefs';
+
+const Context = React.createContext<PlaybackContext | null>(null);
+
+function PlaybackContextProvider({children}: ChildrenProps) {
+    const [currentlyPlayingURL, setCurrentlyPlayingURL] = useState<PlaybackContext['currentlyPlayingURL']>(null);
+    const [sharedElement, setSharedElement] = useState<PlaybackContext['sharedElement']>(null);
+    const [originalParent, setOriginalParent] = useState<OriginalParent>(null);
+    const [currentRouteReportID, setCurrentRouteReportID] = useState<ProtectedCurrentRouteReportID>(NO_REPORT_ID);
+    const resetContextProperties = () => {
+        setSharedElement(null);
+        setOriginalParent(null);
+        setCurrentlyPlayingURL(null);
+        setCurrentRouteReportID(NO_REPORT_ID);
+    };
+
+    const video = usePlaybackContextVideoRefs(resetContextProperties);
+
+    const updateCurrentURLAndReportID: PlaybackContext['updateCurrentURLAndReportID'] = useCallback(
+        (url, reportID) => {
+            if (!url || !reportID) {
+                return;
+            }
+
+            if (currentlyPlayingURL && url !== currentlyPlayingURL) {
+                video.pause();
+            }
+
+            const report = getReportOrDraftReport(reportID);
+            const firstReportIDThatHasURLInAttachments = findUrlInReportOrAncestorAttachments(report, url) ?? NO_REPORT_ID;
+            const isReportAChatThread = isChatThread(report);
+
+            const reportIDtoSet = isReportAChatThread ? firstReportIDThatHasURLInAttachments : reportID;
path: src/components/VideoPlayerContexts/PlaybackContext/index.tsx
user: login: Skalakid
body: How about something like that?

```suggestion
	    const isReportAChatThread = isChatThread(report);
            let reportIDtoSet = null;
            if (isReportAChatThread) {
            	reportIDtoSet= findUrlInReportOrAncestorAttachments(report, url) ?? NO_REPORT_ID;
            } else {
            	reportIDtoSet = reportID
            };
```
created_at: 2025-04-11T14:57:36Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,133 @@
+import React, {useCallback, useContext, useEffect, useMemo, useState} from 'react';
+import type {View} from 'react-native';
+import type {VideoWithOnFullScreenUpdate} from '@components/VideoPlayer/types';
+import {getReportOrDraftReport, isChatThread} from '@libs/ReportUtils';
+import Navigation from '@navigation/Navigation';
+import type ChildrenProps from '@src/types/utils/ChildrenProps';
+import type {ProtectedCurrentRouteReportID} from './playbackContextReportIDUtils';
+import {findUrlInReportOrAncestorAttachments, getCurrentRouteReportID, NO_REPORT_ID, NO_REPORT_ID_IN_PARAMS, normalizeReportID} from './playbackContextReportIDUtils';
+import type {OriginalParent, PlaybackContext} from './types';
+import usePlaybackContextVideoRefs from './usePlaybackContextVideoRefs';
+
+const Context = React.createContext<PlaybackContext | null>(null);
+
+function PlaybackContextProvider({children}: ChildrenProps) {
+    const [currentlyPlayingURL, setCurrentlyPlayingURL] = useState<PlaybackContext['currentlyPlayingURL']>(null);
+    const [sharedElement, setSharedElement] = useState<PlaybackContext['sharedElement']>(null);
+    const [originalParent, setOriginalParent] = useState<OriginalParent>(null);
+    const [currentRouteReportID, setCurrentRouteReportID] = useState<ProtectedCurrentRouteReportID>(NO_REPORT_ID);
+    const resetContextProperties = () => {
+        setSharedElement(null);
+        setOriginalParent(null);
+        setCurrentlyPlayingURL(null);
+        setCurrentRouteReportID(NO_REPORT_ID);
+    };
+
+    const video = usePlaybackContextVideoRefs(resetContextProperties);
+
+    const updateCurrentURLAndReportID: PlaybackContext['updateCurrentURLAndReportID'] = useCallback(
+        (url, reportID) => {
+            if (!url || !reportID) {
+                return;
+            }
+
+            if (currentlyPlayingURL && url !== currentlyPlayingURL) {
+                video.pause();
+            }
+
+            const report = getReportOrDraftReport(reportID);
+            const firstReportIDThatHasURLInAttachments = findUrlInReportOrAncestorAttachments(report, url) ?? NO_REPORT_ID;
+            const isReportAChatThread = isChatThread(report);
+
+            const reportIDtoSet = isReportAChatThread ? firstReportIDThatHasURLInAttachments : reportID;
+
+            const routeReportID = getCurrentRouteReportID(url);
+
+            if (reportIDtoSet === routeReportID || routeReportID === NO_REPORT_ID_IN_PARAMS) {
+                setCurrentRouteReportID(reportIDtoSet);
+            }
+
+            setCurrentlyPlayingURL(url);
+        },
+        [currentlyPlayingURL, video],
+    );
+
+    const shareVideoPlayerElements: PlaybackContext['shareVideoPlayerElements'] = useCallback(
+        (
+            ref: VideoWithOnFullScreenUpdate | null,
+            parent: View | HTMLDivElement | null,
+            child: View | HTMLDivElement | null,
+            shouldNotAutoPlay: boolean,
+            {shouldUseSharedVideoElement, url, reportID},
+        ) => {
+            if (shouldUseSharedVideoElement || url !== currentlyPlayingURL || reportID !== currentRouteReportID) {
+                return;
+            }
+
+            video.updateRef(ref);
+            setOriginalParent(parent);
+            setSharedElement(child);
+            // Prevents autoplay when uploading the attachment
+            if (!shouldNotAutoPlay) {
+                video.play();
+            }
+        },
+        [currentRouteReportID, currentlyPlayingURL, video],
+    );
+
+    useEffect(() => {
+        Navigation.isNavigationReady().then(() => {
+            // This logic ensures that resetVideoPlayerData is only called when currentReportID
+            // changes from one valid value (i.e., not an empty string or '-1') to another valid value.
+            // This prevents the video that plays when the app opens from being interrupted when currentReportID
+            // is initially empty or '-1', or when it changes from empty/'-1' to another value
+            // after the report screen in the central pane is mounted on the large screen.
+            const routeReportID = currentlyPlayingURL ? getCurrentRouteReportID(currentlyPlayingURL) : undefined;
+
+            const isReportIDTheSame = routeReportID === currentRouteReportID || routeReportID === NO_REPORT_ID;
path: src/components/VideoPlayerContexts/PlaybackContext/index.tsx
user: login: Skalakid
body: How about renaming this variable name?
```suggestion
            const isSameReportID = routeReportID === currentRouteReportID || routeReportID === NO_REPORT_ID;
```
created_at: 2025-04-11T15:04:17Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,80 @@
+import {findFocusedRoute} from '@react-navigation/native';
+import type {Route} from '@react-navigation/native';
+import type {OnyxEntry} from 'react-native-onyx';
+import getAttachmentDetails from '@libs/fileDownload/getAttachmentDetails';
+import {getAllReportActions, getReportActionHtml} from '@libs/ReportActionsUtils';
+import {getReportOrDraftReport, isChatThread} from '@libs/ReportUtils';
+import getStateFromPath from '@navigation/helpers/getStateFromPath';
+import Navigation from '@navigation/Navigation';
+import type {ReportDetailsNavigatorParamList} from '@navigation/types';
+import type {Route as ActiveRoute} from '@src/ROUTES';
+import SCREENS from '@src/SCREENS';
+import type {Report} from '@src/types/onyx';
+
+/* NO_REPORT_ID & NO_REPORT_ID_IN_PARAMS are used to differentiate if the ReportID is simply missing or if it is just missing from the route params.
+ * Since both are a unique symbol they should not be used outside of these context files to avoid having to always import them
+ * normalizeReportID is used to return the context value outside so from a calling hook perspective these symbols doesn't matter at all
+ *  */
path: src/components/VideoPlayerContexts/PlaybackContext/playbackContextReportIDUtils.ts
user: login: Skalakid
body: ```suggestion
/* NO_REPORT_ID & NO_REPORT_ID_IN_PARAMS are used to differentiate if the ReportID is simply missing or if it is just missing from the route params.
 * Since both are a unique symbol they should not be used outside of these context files to avoid having to always import them.
 * normalizeReportID is used to return the context value outside, so from a calling hook perspective these symbols doesn't matter at all */
```
created_at: 2025-04-11T15:25:44Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,80 @@
+import {findFocusedRoute} from '@react-navigation/native';
+import type {Route} from '@react-navigation/native';
+import type {OnyxEntry} from 'react-native-onyx';
+import getAttachmentDetails from '@libs/fileDownload/getAttachmentDetails';
+import {getAllReportActions, getReportActionHtml} from '@libs/ReportActionsUtils';
+import {getReportOrDraftReport, isChatThread} from '@libs/ReportUtils';
+import getStateFromPath from '@navigation/helpers/getStateFromPath';
+import Navigation from '@navigation/Navigation';
+import type {ReportDetailsNavigatorParamList} from '@navigation/types';
+import type {Route as ActiveRoute} from '@src/ROUTES';
+import SCREENS from '@src/SCREENS';
+import type {Report} from '@src/types/onyx';
+
+/* NO_REPORT_ID & NO_REPORT_ID_IN_PARAMS are used to differentiate if the ReportID is simply missing or if it is just missing from the route params.
+ * Since both are a unique symbol they should not be used outside of these context files to avoid having to always import them
+ * normalizeReportID is used to return the context value outside so from a calling hook perspective these symbols doesn't matter at all
+ *  */
+const NO_REPORT_ID: unique symbol = Symbol(undefined);
+const NO_REPORT_ID_IN_PARAMS: unique symbol = Symbol(undefined);
+
+const normalizeReportID = (reportID: string | typeof NO_REPORT_ID | typeof NO_REPORT_ID_IN_PARAMS) => {
+    if (reportID === NO_REPORT_ID_IN_PARAMS || reportID === NO_REPORT_ID) {
+        return undefined;
+    }
+
+    return reportID;
+};
+
+type ProtectedCurrentRouteReportID = string | typeof NO_REPORT_ID_IN_PARAMS | typeof NO_REPORT_ID;
+type GetCurrentRouteReportID = (url: string) => string | ProtectedCurrentRouteReportID;
path: src/components/VideoPlayerContexts/PlaybackContext/playbackContextReportIDUtils.ts
user: login: Skalakid
body: Why do we need this? Can't we just define `getCurrentRouteReportID` like that:

```ts
const getCurrentRouteReportID = (url: string): string | ProtectedCurrentRouteReportID => {
	...
}
```
created_at: 2025-04-11T15:31:43Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,80 @@
+import {findFocusedRoute} from '@react-navigation/native';
+import type {Route} from '@react-navigation/native';
+import type {OnyxEntry} from 'react-native-onyx';
+import getAttachmentDetails from '@libs/fileDownload/getAttachmentDetails';
+import {getAllReportActions, getReportActionHtml} from '@libs/ReportActionsUtils';
+import {getReportOrDraftReport, isChatThread} from '@libs/ReportUtils';
+import getStateFromPath from '@navigation/helpers/getStateFromPath';
+import Navigation from '@navigation/Navigation';
+import type {ReportDetailsNavigatorParamList} from '@navigation/types';
+import type {Route as ActiveRoute} from '@src/ROUTES';
+import SCREENS from '@src/SCREENS';
+import type {Report} from '@src/types/onyx';
+
+/* NO_REPORT_ID & NO_REPORT_ID_IN_PARAMS are used to differentiate if the ReportID is simply missing or if it is just missing from the route params.
+ * Since both are a unique symbol they should not be used outside of these context files to avoid having to always import them
+ * normalizeReportID is used to return the context value outside so from a calling hook perspective these symbols doesn't matter at all
+ *  */
+const NO_REPORT_ID: unique symbol = Symbol(undefined);
+const NO_REPORT_ID_IN_PARAMS: unique symbol = Symbol(undefined);
+
+const normalizeReportID = (reportID: string | typeof NO_REPORT_ID | typeof NO_REPORT_ID_IN_PARAMS) => {
+    if (reportID === NO_REPORT_ID_IN_PARAMS || reportID === NO_REPORT_ID) {
+        return undefined;
+    }
+
+    return reportID;
+};
+
+type ProtectedCurrentRouteReportID = string | typeof NO_REPORT_ID_IN_PARAMS | typeof NO_REPORT_ID;
+type GetCurrentRouteReportID = (url: string) => string | ProtectedCurrentRouteReportID;
+type SearchRoute = Omit<Route<string>, 'key'> | undefined;
+type RouteWithReportIDInParams<T> = T & {params: ReportDetailsNavigatorParamList[typeof SCREENS.REPORT_DETAILS.ROOT]};
+
+const getCurrentRouteReportID: GetCurrentRouteReportID = (url): string | typeof NO_REPORT_ID_IN_PARAMS | typeof NO_REPORT_ID => {
+    const route = Navigation.getActiveRouteWithoutParams() as ActiveRoute;
+    const focusedRoute = findFocusedRoute(getStateFromPath(route));
+    const reportIDFromUrlParams = new URLSearchParams(Navigation.getActiveRoute()).get('reportID');
+
+    const focusedRouteReportID = isARouteWithReportIDInParams(focusedRoute) ? focusedRoute.params.reportID : reportIDFromUrlParams;
+
+    if (!focusedRouteReportID) {
+        return NO_REPORT_ID_IN_PARAMS;
+    }
+
+    const report = getReportOrDraftReport(focusedRouteReportID);
+    const isFocusedRouteAChatThread = isChatThread(report);
+    const firstReportThatHasURLInAttachments = findUrlInReportOrAncestorAttachments(report, url);
+
+    return isFocusedRouteAChatThread ? firstReportThatHasURLInAttachments : focusedRouteReportID;
+};
+
+const screensWithReportID = [SCREENS.SEARCH.REPORT_RHP, SCREENS.REPORT, SCREENS.SEARCH.MONEY_REQUEST_REPORT, SCREENS.ATTACHMENTS];
+
+function isARouteWithReportIDInParams(route: SearchRoute): route is RouteWithReportIDInParams<SearchRoute> {
path: src/components/VideoPlayerContexts/PlaybackContext/playbackContextReportIDUtils.ts
user: login: Skalakid
body: Maybe just `hasReportIdInRouteParams`?
created_at: 2025-04-11T15:33:47Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,80 @@
+import {findFocusedRoute} from '@react-navigation/native';
+import type {Route} from '@react-navigation/native';
+import type {OnyxEntry} from 'react-native-onyx';
+import getAttachmentDetails from '@libs/fileDownload/getAttachmentDetails';
+import {getAllReportActions, getReportActionHtml} from '@libs/ReportActionsUtils';
+import {getReportOrDraftReport, isChatThread} from '@libs/ReportUtils';
+import getStateFromPath from '@navigation/helpers/getStateFromPath';
+import Navigation from '@navigation/Navigation';
+import type {ReportDetailsNavigatorParamList} from '@navigation/types';
+import type {Route as ActiveRoute} from '@src/ROUTES';
+import SCREENS from '@src/SCREENS';
+import type {Report} from '@src/types/onyx';
+
+/* NO_REPORT_ID & NO_REPORT_ID_IN_PARAMS are used to differentiate if the ReportID is simply missing or if it is just missing from the route params.
+ * Since both are a unique symbol they should not be used outside of these context files to avoid having to always import them
+ * normalizeReportID is used to return the context value outside so from a calling hook perspective these symbols doesn't matter at all
+ *  */
+const NO_REPORT_ID: unique symbol = Symbol(undefined);
+const NO_REPORT_ID_IN_PARAMS: unique symbol = Symbol(undefined);
+
+const normalizeReportID = (reportID: string | typeof NO_REPORT_ID | typeof NO_REPORT_ID_IN_PARAMS) => {
path: src/components/VideoPlayerContexts/PlaybackContext/playbackContextReportIDUtils.ts
user: login: Skalakid
body: How about moving `ProtectedCurrentRouteReportID` up and changing the argument type to it

```suggestion
const normalizeReportID = (reportID: ProtectedCurrentRouteReportID) => {
```
created_at: 2025-04-11T15:41:39Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,86 @@
+import type {AVPlaybackStatus, AVPlaybackStatusToSet} from 'expo-av';
+import {useCallback, useEffect, useRef} from 'react';
+import type {VideoWithOnFullScreenUpdate} from '@components/VideoPlayer/types';
+import Visibility from '@libs/Visibility';
+import type {PlaybackContext, PlayVideoPromiseRef, StopVideo, UnloadVideo} from './types';
+
+function usePlaybackContextVideoRefs(resetCallback: () => void) {
+    const currentVideoPlayerRef: PlaybackContext['currentVideoPlayerRef'] = useRef(null);
+    const videoResumeTryNumberRef: PlaybackContext['videoResumeTryNumberRef'] = useRef(0);
+    const playVideoPromiseRef: PlayVideoPromiseRef = useRef();
+    const isPlayPendingRef = useRef(false);
+
+    const pauseVideo: PlaybackContext['pauseVideo'] = useCallback(() => {
+        currentVideoPlayerRef.current?.setStatusAsync?.({shouldPlay: false});
+    }, [currentVideoPlayerRef]);
+
+    const stopVideo: StopVideo = useCallback(() => {
+        currentVideoPlayerRef.current?.setStatusAsync?.({shouldPlay: false, positionMillis: 0});
+    }, [currentVideoPlayerRef]);
+
+    const playVideo: PlaybackContext['playVideo'] = useCallback(() => {
+        if (!Visibility.isVisible()) {
+            isPlayPendingRef.current = true;
+            return;
+        }
+        currentVideoPlayerRef.current?.getStatusAsync?.().then((status) => {
+            const newStatus: AVPlaybackStatusToSet = {shouldPlay: true};
+            if ('durationMillis' in status && status.durationMillis === status.positionMillis) {
+                newStatus.positionMillis = 0;
+            }
+            playVideoPromiseRef.current = currentVideoPlayerRef.current?.setStatusAsync(newStatus).catch((error: AVPlaybackStatus) => {
+                return error;
+            });
+        });
+    }, [currentVideoPlayerRef]);
+
+    const unloadVideo: UnloadVideo = useCallback(() => {
+        currentVideoPlayerRef.current?.unloadAsync?.();
+    }, [currentVideoPlayerRef]);
+
+    const checkVideoPlaying: PlaybackContext['checkVideoPlaying'] = useCallback(
path: src/components/VideoPlayerContexts/PlaybackContext/usePlaybackContextVideoRefs.ts
user: login: Skalakid
body: ```suggestion
    const checkIfVideoIsPlaying: PlaybackContext['checkIfVideoIsPlaying'] = useCallback(
```
created_at: 2025-04-11T15:48:53Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,40 @@
+import type {AVPlaybackStatus} from 'expo-av';
+import type {MutableRefObject} from 'react';
+import type {View} from 'react-native';
+import type {VideoWithOnFullScreenUpdate} from '@components/VideoPlayer/types';
+
+type StatusCallback = (isPlaying: boolean) => void;
+type OriginalParent = View | HTMLDivElement | null;
+type UnloadVideo = () => void;
+type StopVideo = () => void;
+type PlayVideoPromiseRef = MutableRefObject<Promise<AVPlaybackStatus> | undefined>;
+
+type VideoElementData = {
+    shouldUseSharedVideoElement: boolean;
+    url: string;
+    reportID: string | undefined;
+};
+
+type PlaybackContext = {
+    updateCurrentURLAndReportID: (url: string | undefined, reportID: string | undefined) => void;
+    currentlyPlayingURL: string | null;
+    currentRouteReportID: string | undefined;
+    originalParent: View | HTMLDivElement | null;
+    sharedElement: View | HTMLDivElement | null;
+    videoResumeTryNumberRef: MutableRefObject<number>;
+    currentVideoPlayerRef: MutableRefObject<VideoWithOnFullScreenUpdate | null>;
+    shareVideoPlayerElements: (
+        ref: VideoWithOnFullScreenUpdate | null,
+        parent: View | HTMLDivElement | null,
+        child: View | HTMLDivElement | null,
+        isUploading: boolean,
+        videoElementData: VideoElementData,
+    ) => void;
+    playVideo: () => void;
+    pauseVideo: () => void;
+    checkVideoPlaying: (statusCallback: StatusCallback) => void;
+    setCurrentlyPlayingURL: React.Dispatch<React.SetStateAction<string | null>>;
+    resetVideoPlayerData: () => void;
+};
path: src/components/VideoPlayerContexts/PlaybackContext/types.ts
user: login: Skalakid
body: I see that you are using this in both context and hook and you are assigning function types using `PlaybackContext['...']`. Maybe we can split this object into 2 separate ones and instead of assigning every function type, just add the type to the context/hook return value?
For example in hook:
```
return {
        resetPlayerData: resetVideoPlayerData,
        isPlaying: checkVideoPlaying,
        pause: pauseVideo,
        play: playVideo,
        ref: currentVideoPlayerRef,
        resumeTryNumberRef: videoResumeTryNumberRef,
        updateRef: updateCurrentVideoPlayerRef,
} as PlaybackContextVideoRefs
```

and in context:

```
type PlaybackContext = PlaybackContextValues & PlaybackContextVideoRefs
return {
       ...
} as PlaybackContext
```

(of course you can choose better type names than me in the example)
created_at: 2025-04-11T16:02:54Z
author_association: CONTRIBUTOR
diff_hunk: @@ -50,14 +50,14 @@ type VideoPlayerPreviewProps = {
 function VideoPlayerPreview({videoUrl, thumbnailUrl, reportID, fileName, videoDimensions, videoDuration, onShowModalPress, isDeleted}: VideoPlayerPreviewProps) {
     const styles = useThemeStyles();
     const {translate} = useLocalize();
-    const {currentlyPlayingURL, currentlyPlayingURLReportID, updateCurrentlyPlayingURL} = usePlaybackContext();
-    const {shouldUseNarrowLayout} = useResponsiveLayout();
+    const {currentlyPlayingURL, currentRouteReportID, updateCurrentURLAndReportID} = usePlaybackContext();
+    // eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth
+    const {isSmallScreenWidth} = useResponsiveLayout();
path: src/components/VideoPlayerPreview/index.tsx
user: login: Skalakid
body: Why not `shouldUseNarrowLayout`? `isInNarrowPaneModal` from inside of it breaks something?
created_at: 2025-04-11T16:07:10Z
author_association: CONTRIBUTOR
diff_hunk: @@ -50,14 +50,14 @@ type VideoPlayerPreviewProps = {
 function VideoPlayerPreview({videoUrl, thumbnailUrl, reportID, fileName, videoDimensions, videoDuration, onShowModalPress, isDeleted}: VideoPlayerPreviewProps) {
     const styles = useThemeStyles();
     const {translate} = useLocalize();
-    const {currentlyPlayingURL, currentlyPlayingURLReportID, updateCurrentlyPlayingURL} = usePlaybackContext();
-    const {shouldUseNarrowLayout} = useResponsiveLayout();
+    const {currentlyPlayingURL, currentRouteReportID, updateCurrentURLAndReportID} = usePlaybackContext();
+    // eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth
+    const {isSmallScreenWidth} = useResponsiveLayout();
path: src/components/VideoPlayerPreview/index.tsx
user: login: Skalakid
body: If it fixes a bug maybe let's add a comment here 
created_at: 2025-04-11T16:08:02Z
author_association: CONTRIBUTOR
diff_hunk: @@ -31,11 +31,11 @@ function VideoRenderer({tnode, key}: VideoRendererProps) {
         <ShowContextMenuContext.Consumer>
             {({report}) => (
                 <AttachmentContext.Consumer>
-                    {({accountID, type, hashKey}) => (
+                    {({accountID, type, hashKey, reportID}) => (
                         <VideoPlayerPreview
                             key={key}
                             videoUrl={sourceURL}
-                            reportID={report?.reportID}
+                            reportID={reportID ?? report?.reportID}
path: src/components/HTMLEngineProvider/HTMLRenderers/VideoRenderer.tsx
user: login: JakubKorytko
body: Yes, not different numbers, but reportID is undefined in Reports->Chats and in rare cases for attachment modal view report?.reportID can be undefined.
created_at: 2025-04-14T08:00:44Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,78 @@
+import {findFocusedRoute} from '@react-navigation/native';
+import type {Route} from '@react-navigation/native';
+import type {OnyxEntry} from 'react-native-onyx';
+import getAttachmentDetails from '@libs/fileDownload/getAttachmentDetails';
+import {getAllReportActions, getReportActionHtml} from '@libs/ReportActionsUtils';
+import {getReportOrDraftReport, isChatThread} from '@libs/ReportUtils';
+import getStateFromPath from '@navigation/helpers/getStateFromPath';
+import Navigation from '@navigation/Navigation';
+import type {ReportDetailsNavigatorParamList} from '@navigation/types';
+import type {Route as ActiveRoute} from '@src/ROUTES';
+import SCREENS from '@src/SCREENS';
+import type {Report} from '@src/types/onyx';
+
+/* NO_REPORT_ID & NO_REPORT_ID_IN_PARAMS are used to differentiate if the ReportID is simply missing or if it is just missing from the route params.
+ * Since both are a unique symbol they should not be used outside of these context files to avoid having to always import them.
+ * normalizeReportID is used to return the context value outside, so from a calling hook perspective these symbols doesn't matter at all */
+const NO_REPORT_ID: unique symbol = Symbol(undefined);
+const NO_REPORT_ID_IN_PARAMS: unique symbol = Symbol(undefined);
+type ProtectedCurrentRouteReportID = string | typeof NO_REPORT_ID_IN_PARAMS | typeof NO_REPORT_ID;
+
+const normalizeReportID = (reportID: ProtectedCurrentRouteReportID) => {
+    if (reportID === NO_REPORT_ID_IN_PARAMS || reportID === NO_REPORT_ID) {
+        return undefined;
+    }
+
+    return reportID;
+};
+
+type SearchRoute = Omit<Route<string>, 'key'> | undefined;
+type RouteWithReportIDInParams<T> = T & {params: ReportDetailsNavigatorParamList[typeof SCREENS.REPORT_DETAILS.ROOT]};
+
+const getCurrentRouteReportID: (url: string) => string | ProtectedCurrentRouteReportID = (url): string | typeof NO_REPORT_ID_IN_PARAMS | typeof NO_REPORT_ID => {
+    const route = Navigation.getActiveRouteWithoutParams() as ActiveRoute;
+    const focusedRoute = findFocusedRoute(getStateFromPath(route));
+    const reportIDFromUrlParams = new URLSearchParams(Navigation.getActiveRoute()).get('reportID');
+
+    const focusedRouteReportID = hasReportIdInRouteParams(focusedRoute) ? focusedRoute.params.reportID : reportIDFromUrlParams;
+
+    if (!focusedRouteReportID) {
+        return NO_REPORT_ID_IN_PARAMS;
+    }
+
+    const report = getReportOrDraftReport(focusedRouteReportID);
+    const isFocusedRouteAChatThread = isChatThread(report);
+    const firstReportThatHasURLInAttachments = findUrlInReportOrAncestorAttachments(report, url);
+
+    return isFocusedRouteAChatThread ? firstReportThatHasURLInAttachments : focusedRouteReportID;
+};
+
+const screensWithReportID = [SCREENS.SEARCH.REPORT_RHP, SCREENS.REPORT, SCREENS.SEARCH.MONEY_REQUEST_REPORT, SCREENS.ATTACHMENTS];
+
+function hasReportIdInRouteParams(route: SearchRoute): route is RouteWithReportIDInParams<SearchRoute> {
path: src/components/VideoPlayerContexts/PlaybackContext/playbackContextReportIDUtils.ts
user: login: mountiny
body: ```suggestion
function hasReportIDInRouteParams(route: SearchRoute): route is RouteWithReportIDInParams<SearchRoute> {
```
created_at: 2025-04-14T15:36:52Z
author_association: CONTRIBUTOR

PR comments:
user: login: melvin-bot[bot]
created_at: 2025-04-09T10:20:01Z
body: @DylanDylann Please copy/paste the Reviewer Checklist from [here](https://raw.githubusercontent.com/Expensify/App/main/contributingGuides/REVIEWER_CHECKLIST.md) into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]
author_association: NONE
user: login: DylanDylann
created_at: 2025-04-10T05:13:51Z
body: Can't play the video after reloading

https://github.com/user-attachments/assets/f1ea6155-7517-4ff6-bdd8-8cdbe6e19c9a


author_association: CONTRIBUTOR
user: login: DylanDylann
created_at: 2025-04-10T09:56:14Z
body: Discovered some problems on mobile. Discussin with the author on Slack 
author_association: CONTRIBUTOR
user: login: github-actions[bot]
created_at: 2025-04-11T13:10:49Z
body: 🚧 @mountiny has triggered a test app build. You can view the [workflow run here](https://github.com/Expensify/App/actions/runs/14403908042).
author_association: CONTRIBUTOR
user: login: github-actions[bot]
created_at: 2025-04-11T13:49:59Z
body: :test_tube::test_tube: Use the links below to test this adhoc build on Android, iOS, Desktop, and Web. Happy testing! :test_tube::test_tube:
| Android :robot:  | iOS :apple: |
| ------------- | ------------- |
| Android :robot::arrows_counterclockwise:  | iOS :apple::arrows_counterclockwise: |
| https://ad-hoc-expensify-cash.s3.amazonaws.com/android/59896-hybrid/index.html  | https://ad-hoc-expensify-cash.s3.amazonaws.com/ios/59896-hybrid/index.html  |
| ![Android](https://api.qrserver.com/v1/create-qr-code/?size=120x120&data=https://ad-hoc-expensify-cash.s3.amazonaws.com/android/59896-hybrid/index.html)  | ![iOS](https://api.qrserver.com/v1/create-qr-code/?size=120x120&data=https://ad-hoc-expensify-cash.s3.amazonaws.com/ios/59896-hybrid/index.html)  |
| Desktop :computer: | Web :spider_web: |
| https://ad-hoc-expensify-cash.s3.amazonaws.com/desktop/59896/NewExpensify.dmg  | https://59896.pr-testing.expensify.com  |
| ![Desktop](https://api.qrserver.com/v1/create-qr-code/?size=120x120&data=https://ad-hoc-expensify-cash.s3.amazonaws.com/desktop/59896/NewExpensify.dmg)  | ![Web](https://api.qrserver.com/v1/create-qr-code/?size=120x120&data=https://59896.pr-testing.expensify.com)  |

---

:eyes: [View the workflow run that generated this build](https://github.com/Expensify/App/actions/runs/14403908042) :eyes:

author_association: CONTRIBUTOR
user: login: DylanDylann
created_at: 2025-04-14T14:49:15Z
body: ## Reviewer Checklist

- [x] I have verified the author checklist is complete (all boxes are checked off). 
- [x] I verified the correct issue is linked in the `### Fixed Issues` section above
- [x] I verified testing steps are clear and they cover the changes made in this PR
    - [x] I verified the steps for local testing are in the `Tests` section
    - [x] I verified the steps for Staging and/or Production testing are in the `QA steps` section
    - [x] 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)
    - [x] 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)
- [x] I checked that screenshots or videos are included for tests on [all platforms](https://github.com/Expensify/App/blob/main/contributingGuides/CONTRIBUTING.md#make-sure-you-can-test-on-all-platforms)
- [x] I included screenshots or videos for tests on [all platforms](https://github.com/Expensify/App/blob/main/contributingGuides/CONTRIBUTING.md#make-sure-you-can-test-on-all-platforms)
- [x] I verified tests pass on **all platforms** & I tested again on:
    - [x] Android: Native
    - [x] Android: mWeb Chrome
    - [x] iOS: Native
    - [x] iOS: mWeb Safari
    - [x] MacOS: Chrome / Safari
    - [x] MacOS: Desktop
- [x] 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
- [x] I verified proper code patterns were followed (see [Reviewing the code](https://github.com/Expensify/App/blob/main/contributingGuides/PR_REVIEW_GUIDELINES.md#reviewing-the-code))
    - [x] 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`).
    - [x] I verified that the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. `myBool && <MyComponent />`.
    - [x] I verified that comments were added to code that is not self explanatory
    - [x] 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.
    - [x] I verified any copy / text shown in the product is localized by adding it to `src/languages/*` files and using the [translation method](https://github.com/Expensify/App/blob/4bd99402cebdf4d7394e0d1f260879ea238197eb/src/components/withLocalize.js#L60)
    - [x] I verified all numbers, amounts, dates and phone numbers shown in the product are using the [localization methods](https://github.com/Expensify/App/blob/4bd99402cebdf4d7394e0d1f260879ea238197eb/src/components/withLocalize.js#L60-L68)
    - [x] 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)
    - [x] 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.
    - [x] I verified the JSDocs style guidelines (in [`STYLE.md`](https://github.com/Expensify/App/blob/main/contributingGuides/STYLE.md#jsdocs)) were followed
- [x] If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
- [x] I verified that this PR follows the guidelines as stated in the [Review Guidelines](https://github.com/Expensify/App/blob/main/contributingGuides/PR_REVIEW_GUIDELINES.md)
- [x] 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)
- [x] I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
- [x] I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
- [x] If a new component is created I verified that:
    - [x] A similar component doesn't exist in the codebase
    - [x] All props are defined accurately and each prop has a `/** comment above it */`
    - [x] The file is named correctly
    - [x] The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    - [x] The only data being stored in the state is data necessary for rendering and nothing else
    - [x] 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)
    - [x] 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`)
    - [x] All JSX used for rendering exists in the render method
    - [x] 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
- [x] If any new file was added I verified that:
    - [x] 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
- [x] If a new CSS style is added I verified that:
    - [x] A similar style doesn't already exist
    - [x] The style can't be created with an existing [StyleUtils](https://github.com/Expensify/App/blob/main/src/utils/index.ts) function (i.e. `StyleUtils.getBackgroundAndBorderStyle(theme.componentBG`)
- [x] 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.
- [x] 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)
- [x] 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.
- [x] 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.
- [x] 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:
    - [x] I verified that all the inputs inside a form are aligned with each other.
    - [x] I added `Design` label and/or tagged `@Expensify/design` so the design team can review the changes.
- [x] 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.
- [x] 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.
- [x] I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

### Screenshots/Videos
<details>
<summary>Android: Native</summary>

<!-- add screenshots or videos here -->

https://github.com/user-attachments/assets/2e639be3-b6bb-4199-ac03-53dc9517af6b


</details>

<details>
<summary>Android: mWeb Chrome</summary>

<!-- add screenshots or videos here -->

https://github.com/user-attachments/assets/e7cf0c3b-a323-4bd5-916c-40edfd5dad1b


</details>

<details>
<summary>iOS: Native</summary>

<!-- add screenshots or videos here -->

https://github.com/user-attachments/assets/a788f06b-3aee-46a2-8096-b7f950dc7517



</details>

<details>
<summary>iOS: mWeb Safari</summary>

<!-- add screenshots or videos here -->

https://github.com/user-attachments/assets/d2c6713a-4bb9-4367-9b2b-f241c510aa7c


</details>

<details>
<summary>MacOS: Chrome / Safari</summary>

https://github.com/user-attachments/assets/6d094f66-10f2-48e9-afbe-665b6216970c


<!-- add screenshots or videos here -->

</details>

<details>
<summary>MacOS: Desktop</summary>

<!-- add screenshots or videos here -->

https://github.com/user-attachments/assets/243d47c6-40cc-4525-8c3e-f1ededa80d24



</details>

author_association: CONTRIBUTOR
user: login: OSBotify
created_at: 2025-04-14T15:50:19Z
body: :hand: This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.
author_association: CONTRIBUTOR
user: login: github-actions[bot]
created_at: 2025-04-14T23:17:40Z
body: 🚀 [Deployed](https://github.com/Expensify/App/actions/runs/14457123056) to staging by https://github.com/mountiny in version: 9.1.28-0 🚀

platform | result
---|---
🖥 desktop 🖥|success ✅
🕸 web 🕸|success ✅
🤖 android 🤖|success ✅
🍎 iOS 🍎|success ✅
author_association: CONTRIBUTOR
user: login: github-actions[bot]
created_at: 2025-04-16T22:13:52Z
body: 🚀 [Deployed](https://github.com/Expensify/App/actions/runs/14502397000) to production by https://github.com/marcaaron in version: 9.1.28-15 🚀

platform | result
---|---
🖥 desktop 🖥|success ✅
🕸 web 🕸|success ✅
🤖 android 🤖|failure ❌
🍎 iOS 🍎|success ✅
author_association: CONTRIBUTOR