Skip to content

[$175] Attachment – Unable to Open Video in Thread Chat #106627

Open

Description

@vincdargento

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: v9.5.36-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from TestRail: https://github.com/Expensify/Expensify/issues/621188
Email or phone of affected tester (no customers): N/A
Issue reported by: Applause Internal Team

Action Performed:

  1. Navigate to staging.new.expensify.com.
  2. Open the app.
  3. Send a video in any chat.
  4. Change the playback speed to 2x.
  5. Reply to the video to create a thread.
  6. Open the thread and try to play the video.

Expected Result:

The video opens and plays in the thread.

Actual Result:

The video does not open in the thread chat.

Workaround:

N/A

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari

Screenshots/Videos

Bug7288611_1792194282519.bandicam_2026-10-17_02-39-18-183.mp4
Upwork Automation - Do Not Edit

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Nov 11, 2026
  2. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Nov 11, 2026
  3. melvin-bot commented on Nov 11, 2026

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @FitseTLT (External)

  4. changed the title [-]Attachment – Unable to Open Video in Thread Chat[/-] [+][$175] Attachment – Unable to Open Video in Thread Chat[/+] on Nov 11, 2026
  5. melvin-bot commented on Nov 11, 2026

    @melvin-bot
  6. MelvinBot commented on Nov 11, 2026

    @MelvinBot
    Contributor

    🤖 Web test steps verification results: ⚠️ partial

    Verified app and chat access on dev NewDot web. Video reproduction is blocked: uploads are outside supported agent-device web capabilities, and the available chat contains no video.

    Concierge chat with welcome message and no video attachment

    Step Status
    1. Navigate to appConfirmed authenticated access to dev NewDot; staging was not tested.
    ✅
    2. Open app/chatOpened Concierge and confirmed the message composer.
    Concierge chat with welcome message and no video attachment
    ✅
    3. Send a videoBlocked by unsupported upload automation, not an observed App failure. No existing video fixture was available.
    ❌
    4. Change playback speed to 2xNot exercised because video setup was blocked.
    ❌
    5. Reply to create a threadNot exercised because video setup was blocked.
    ❌
    6. Open/play the original video in the thread — preliminary analysisConfidence: low; root cause remains unconfirmed.

    Candidate mechanism: A newly mounted thread preview starts as a thumbnail. Desktop clicks update the globally selected video, but activation depends on that selection changing. If the same attachment is already selected when the thread mounts, clicking it may leave the thumbnail inactive. See VideoPlayerPreview/index.tsx:62–74 and 112–131.

    Counterevidence: Parent-player cleanup clears the selected URL, which could prevent this failure. Its timing relative to thread mounting is unverified; see BaseVideoPlayer.tsx:428–440. The candidate also predicts possible failure at 1x, so it does not establish a speed-specific cause.

    Required confirmation: Reproduce with an existing video at both 1x and 2x. At the failed click, check whether the thread still shows a thumbnail and whether the selected URL/report identity changes. If a player mounts successfully, investigate playback rather than thumbnail activation.

    Recommendation: Do not implement a fix yet. Runtime reproduction and equivalence with the reported release remain unverified.
    ❌

    view run · no recording available

  7. TassioSales commented on Nov 11, 2026

    @TassioSales

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    In a thread chat, tapping or clicking on an attached video preview fails to open the video modal/player or errors silently.

    What is the root cause of that problem?

    In AttachmentModal.tsx and ReportActionItemSingle.tsx / AttachmentView.tsx:
    When rendering attachments within a thread report context, the parent reportID passed to the attachment modal resolver defaults to the active thread's reportID instead of resolving the original message's attachment source URL via the parent report action. The attachment source URL generation assumes standard 1:1 chat context, causing the video source URL resolver to encounter a missing source URI or invalid permissions token in thread view.

    What changes do you think we should make in order to solve the problem?

    1. In src/components/AttachmentModal.tsx and src/components/ReportActionItem/AttachmentView.tsx:
      • Ensure source and originalFileName resolution checks if the active report is a thread (ReportUtils.isChatThread(report)) and falls back to the parent report action's attachment URL with proper auth tokens.
    2. In src/libs/actions/Report.ts (openReportAttachmentModal):
      • Pass the explicit reportActionID and parent reportID so the video player receives the fully qualified authenticated attachment URL.

    What alternative solutions did you explore? (Optional)

    Attempting to proxy attachment URLs without the auth token header, which fails for secure attachments.

  8. HindsightWise commented on Nov 11, 2026

    @HindsightWise

    Contributor details
    Your Expensify account email: hindsightwise@gmail.com
    Upwork Profile Link: https://www.upwork.com/freelancers/~013d295f05a578824b

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    When a user sends a video in a chat, plays the video inline (and optionally changes the playback speed to 2x), and then clicks Reply in thread to open the thread chat, clicking the Play button on the parent video thumbnail at the top of the thread does nothing—the video remains stuck on the thumbnail and never opens or plays.

    What is the root cause of that problem?

    1. How the video preview is rendered inside the thread header (00:08–00:14 of the QA recording):

    2. Why prevPlaybackKey in VideoPlayerPreview ignores the Play click in the thread:

      • Look at VideoPlayerPreview in src/components/VideoPlayerPreview/index.tsx:112-131 (introduced when useEffect was converted to a render-phase playbackKey comparison in PR #83382):
        const handleOnPress = () => {
            updateCurrentURLAndReportID(videoUrl, report, reportID);
            if (isSmallScreenWidth) {
                onShowModalPress();
            }
        };
        
        useEffect(() => {
            return navigation.addListener('blur', () => !isOnAttachmentRoute() && setIsThumbnail(true));
        }, [navigation]);
        
        const playbackKey = `${currentlyPlayingURL}|${currentRouteReportID}|${videoUrl}|${reportID}|${isOnSearch}`;
        const [prevPlaybackKey, setPrevPlaybackKey] = useState(playbackKey);
        if (prevPlaybackKey !== playbackKey) {
            setPrevPlaybackKey(playbackKey);
            const isFocused = doesUserRemainOnFirstRenderRoute();
            if (videoUrl === currentlyPlayingURL && reportID === currentRouteReportID && isFocused) {
                setIsThumbnail(false);
            }
        }
      • When the user first plays the video in the parent chat (5409533764521432) and changes its playback speed to 2x, PlaybackContext sets:
        • currentlyPlayingURL = videoUrl
        • currentRouteReportID = "5409533764521432"
      • When the user then clicks Reply in thread, the app navigates to the thread report (487551176124257):
        1. In PlaybackContext (src/components/VideoPlayerContexts/PlaybackContext/index.tsx:111-134), getCurrentRouteReportID(currentlyPlayingURL) sees that the focused route (487551176124257) is a chat thread (isChatThread(report) === true), calls findURLInReportOrAncestorAttachments(report, url), finds the video in the parent report's actions, and returns "5409533764521432" (and isURLStillMounted is also true because the parent screen stays mounted in the stack). Thus PlaybackContext does not reset, leaving currentlyPlayingURL === videoUrl and currentRouteReportID === "5409533764521432".
        2. When the thread screen mounts its own VideoPlayerPreview for the parent action, isThumbnail initializes to useState(true), and prevPlaybackKey initializes to useState(playbackKey) where playbackKey is already:
          "${videoUrl}|5409533764521432|${videoUrl}|5409533764521432|false".
        3. Because prevPlaybackKey === playbackKey on initial mount, the if (prevPlaybackKey !== playbackKey) block does not run on mount.
        4. When the user clicks the Play button on the video thumbnail in the thread (00:08–00:13), handleOnPress calls updateCurrentURLAndReportID(videoUrl, report, "5409533764521432"). That sets currentlyPlayingURL to the exact same videoUrl and currentRouteReportID to the exact same "5409533764521432".
        5. Neither currentlyPlayingURL nor currentRouteReportID changes (playbackKey is unchanged!), and handleOnPress never calls setIsThumbnail(false) directly on wide screens (!isSmallScreenWidth). As a result, isThumbnail stays true forever and BaseVideoPlayer never mounts!

    What changes do you think we should make in order to solve the problem?

    In src/components/VideoPlayerPreview/index.tsx:

    1. In handleOnPress, when on a wide layout (!isSmallScreenWidth), directly set setIsThumbnail(false) so pressing the thumbnail Play button always transitions the clicked VideoPlayerPreview from thumbnail to VideoPlayer even when currentlyPlayingURL and currentRouteReportID in PlaybackContext already match this videoUrl and reportID (such as when opening a thread after playing the parent video, or returning to a blurred screen where navigation.addListener('blur') reset isThumbnail to true while playbackKey remained unchanged):
        const handleOnPress = () => {
            updateCurrentURLAndReportID(videoUrl, report, reportID);
            if (isSmallScreenWidth) {
                onShowModalPress();
            } else {
                setIsThumbnail(false);
            }
        };
    1. Add a unit test in tests/unit/VideoPlayerPreviewTest.tsx verifying that when PlaybackContext already holds matching currentlyPlayingURL === videoUrl and currentRouteReportID === reportID at the time VideoPlayerPreview mounts (or after a navigation blur event resets isThumbnail to true), pressing the thumbnail on a wide screen (isSmallScreenWidth = false) transitions isThumbnail to false and renders VideoPlayer.

    What alternative solutions did you explore? (Optional)

    • Initializing prevPlaybackKey to null (useState<string | null>(null)) so the if (prevPlaybackKey !== playbackKey) block also runs on mount: If prevPlaybackKey started as null, mounting the thread screen while the parent video was playing (or paused as the last active video) would immediately auto-replace the thumbnail and auto-play the video inside the thread header as soon as the user clicked "Reply in thread", even if the user only wanted to type a reply. Setting setIsThumbnail(false) inside handleOnPress (when !isSmallScreenWidth) keeps the thread header as a clean thumbnail on thread open and reliably mounts and plays VideoPlayer (inheriting the 2x currentPlaybackSpeed via VideoPopoverMenuContext.tsx:45-53) the moment the user clicks Play.

    — submitted with Antigravity on the contributor's behalf

  9. melvin-bot commented on Nov 11, 2026

    @melvin-bot

    ✅ Contributor details stored successfully. Thank you for contributing to Expensify!

  10. tranvanminhnhat commented on Nov 11, 2026

    @tranvanminhnhat

    Contributor details
    Your Expensify account email: tranvanminhnhat99@gmail.com
    Upwork Profile Link: https://www.upwork.com/freelancers/~01867c2936746cf5ca

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    In a thread chat on desktop/web, clicking on an attached video thumbnail fails to mount and play the video player inline.

    What is the root cause of that problem?

    When clicking on a video thumbnail in a thread, handleOnPress in VideoPlayerPreview/index.tsx triggers updateCurrentURLAndReportID in PlaybackContext/index.tsx.

    1. In PlaybackContext/index.tsx:58-65, when the active report is a thread (isChatThread(report) is true), it normalizes the report ID by looking up ancestor attachments:

      const reportIDtoSet = isReportAChatThread ? (findURLInReportOrAncestorAttachments(report, url) ?? NO_REPORT_ID) : reportID;
      setCurrentRouteReportID(reportIDtoSet);

      Consequently, currentRouteReportID is set to the parent report's ID.

    2. However, the VideoPlayerPreview mounted inside the thread receives reportID as the thread's own reportID.
      In VideoPlayerPreview/index.tsx:128-130:

      if (videoUrl === currentlyPlayingURL && reportID === currentRouteReportID && isFocused) {
          setIsThumbnail(false);
      }

      Because reportID (thread report ID) does not match currentRouteReportID (parent report ID), the condition evaluates to false. Therefore, setIsThumbnail(false) is never called, and the preview remains permanently stuck in thumbnail mode without mounting the video player.

    What changes do you think we should make in order to solve the problem?

    In src/components/VideoPlayerPreview/index.tsx:
    When verifying whether the active video matches the preview:
    Check if reportID === currentRouteReportID OR if report is a chat thread whose parent/ancestor report matches currentRouteReportID (e.g. report?.parentReportID === currentRouteReportID or findURLInReportOrAncestorAttachments(report, videoUrl) === currentRouteReportID).

    Alternatively, in VideoPlayerPreview/index.tsx, when invoking handleOnPress:
    Pass the normalized report ID corresponding to the ancestor attachment context so that reportID passed to VideoPlayerPreview and currentRouteReportID in PlaybackContext stay consistent.

    What alternative solutions did you explore? (Optional)

    Bypassing the reportID === currentRouteReportID check entirely: Not recommended because multiple chats or search results may display the same video attachment, and we only want the focused instance to switch from thumbnail to active player.

    What automated tests can you add to prevent this from re-occurring?

    In tests/unit/VideoPlayerPreviewTest.tsx:
    Add a test verifying that when a video attachment is rendered inside a thread report context, triggering playback successfully switches isThumbnail to false and mounts the player.

  11. melvin-bot commented on Nov 11, 2026

    @melvin-bot

    ✅ Contributor details stored successfully. Thank you for contributing to Expensify!

  12. kevinjosh10 commented on Nov 12, 2026

    @kevinjosh10

    Proposal

    What is the root cause of that problem?

    There are two distinct root causes that combine to completely block video playback inside thread chats on desktop/web:

    1. reportID mismatch between thread and normalized ancestor report in PlaybackContext:

      • In PlaybackContext/index.tsx:58-65, when updateCurrentURLAndReportID is called with a thread report (isChatThread(report) is true), setCurrentRouteReportID does not set the thread's own report ID. Instead, it resolves the ancestor report ID where the attachment originated via findURLInReportOrAncestorAttachments(report, url):
        const isReportAChatThread = isChatThread(report);
        const reportIDtoSet = isReportAChatThread ? (findURLInReportOrAncestorAttachments(report, url) ?? NO_REPORT_ID) : reportID;
        setCurrentRouteReportID(reportIDtoSet);
        As a result, currentRouteReportID in PlaybackContext is set to parentReport.reportID.
      • However, in VideoPlayerPreview/index.tsx:128-130, the component receives reportID as the thread's report ID (threadReport.reportID). It checks:
        if (videoUrl === currentlyPlayingURL && reportID === currentRouteReportID && isFocused) {
            setIsThumbnail(false);
        }
        Because reportID (threadReport.reportID) does not equal currentRouteReportID (parentReport.reportID), this check evaluates to false. setIsThumbnail(false) is never called, leaving the video permanently trapped in thumbnail mode.
    2. handleOnPress fails to transition isThumbnail and stale playbackKey state prevents re-evaluation:

      • In VideoPlayerPreview/index.tsx:112-117:
        const handleOnPress = () => {
            updateCurrentURLAndReportID(videoUrl, report, reportID);
            if (isSmallScreenWidth) {
                onShowModalPress();
            }
        };
        On wide screens (!isSmallScreenWidth), clicking the thumbnail's play button is an explicit user intent to mount and play the video inline. However, handleOnPress does not call setIsThumbnail(false) directly; it delegates thumbnail toggling solely to the prevPlaybackKey !== playbackKey render check (VideoPlayerPreview/index.tsx:123-131).
      • When the user previously played the video in the parent chat (e.g., at 2x speed as described in Step 4), currentlyPlayingURL is already videoUrl, and currentRouteReportID is already parentReport.reportID.
      • When the user opens the thread and clicks the thumbnail, updateCurrentURLAndReportID(videoUrl, report, reportID) sets currentlyPlayingURL and currentRouteReportID to the exact same values they already held. Consequently, playbackKey does not change (prevPlaybackKey !== playbackKey evaluates to false), so the thumbnail state transition is never even triggered.

    What changes do you think we should make in order to solve the problem?

    1. In src/components/VideoPlayerPreview/index.tsx:

    Directly set setIsThumbnail(false) in handleOnPress on wide screens (!isSmallScreenWidth), and update the playback matching condition to support thread reports whose ancestor attachment matches currentRouteReportID:

    // 1. Imports in src/components/VideoPlayerPreview/index.tsx:
    import {findURLInReportOrAncestorAttachments} from '@components/VideoPlayerContexts/PlaybackContext/playbackContextReportIDUtils';
    import {isChatThread} from '@libs/ReportUtils';
    
    // 2. In handleOnPress: toggle thumbnail on wide screen:
    const handleOnPress = () => {
        updateCurrentURLAndReportID(videoUrl, report, reportID);
        if (isSmallScreenWidth) {
            onShowModalPress();
        } else {
            setIsThumbnail(false);
        }
    };
    
    // 3. In the playbackKey transition check: support thread ancestor matching:
    if (prevPlaybackKey !== playbackKey) {
        setPrevPlaybackKey(playbackKey);
        const isFocused = doesUserRemainOnFirstRenderRoute();
        const isMatchingReport = reportID === currentRouteReportID || (isChatThread(report) && findURLInReportOrAncestorAttachments(report, videoUrl) === currentRouteReportID);
        if (videoUrl === currentlyPlayingURL && isMatchingReport && isFocused) {
            setIsThumbnail(false);
        }
    }

    What alternative solutions did you explore? (Optional)

    • Only setting setIsThumbnail(false) in handleOnPress without updating the playbackKey check:
      While setting setIsThumbnail(false) directly in handleOnPress resolves the immediate user click, if playback is triggered externally or when navigating between related chats, the thumbnail would fail to activate because reportID === currentRouteReportID remains false for thread reports. Doing both ensures airtight reliability.
    • Normalizing currentRouteReportID inside VideoPlayerPreview props:
      Passing the ancestor report ID into VideoPlayerPreview would break downstream components like VideoPlayer (src/components/VideoPlayer/index.tsx) and useReportActions which require the real reportID of the current screen to load comments and thread actions. Resolving isMatchingReport within VideoPlayerPreview preserves the integrity of reportID.

    What automated tests can you add to prevent this from re-occurring?

    In tests/unit/VideoPlayerPreviewTest.tsx:

    1. Verify that pressing the thumbnail on wide screen (isSmallScreenWidth: false) sets isThumbnail to false and renders VideoPlayer.
    2. Verify that when VideoPlayerPreview is rendered inside a chat thread report (isChatThread(report) === true) and currentRouteReportID in PlaybackContext matches the parent report ID where the video originated, isMatchingReport resolves to true and activates the player.

    Contributor details

    Your Expensify account email: lkevinjosh10@gmail.com
    Upwork Profile Link: https://www.upwork.com/freelancers/~0131dae36abcf59374

  13. melvin-bot commented on Nov 12, 2026

    @melvin-bot

    ✅ Contributor details stored successfully. Thank you for contributing to Expensify!

  14. cocvn157 commented on Nov 13, 2026

    @cocvn157

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    On Web desktop (!isSmallScreenWidth), after sending and playing a video inline in a chat (and changing playback speed to 2x), clicking Reply in thread to open the thread and then clicking the Play button on the parent video thumbnail in the thread header does nothing—the attachment stays stuck as a thumbnail instead of mounting the inline video player and playing at 2x.

    What is the root cause of that problem?

    1. Parent video in a thread header shares the parent reportID, while ScreenFreezeWrapper on Web freezes the parent screen before BaseVideoPlayer can unmount and clear PlaybackContext:

      • Inside the thread screen, ReportActionItemParentAction (src/pages/inbox/report/ReportActionItemParentAction.tsx:61,123-126) resolves ancestors via useAncestors and renders <AncestorReportActionItem report={ancestorReport} ... /> (src/pages/inbox/report/AncestorReportActionItem.tsx:171-186), which passes reportID = ancestorReport.reportID (the parent chat's reportID, not the thread's reportID) down through ReportActionItem -> ActionContentRouter -> ChatMessageContent (AttachmentContext.Provider at src/pages/inbox/report/actionContents/ChatMessageContent.tsx:67,86) -> VideoRenderer -> VideoPlayerPreview (src/components/HTMLEngineProvider/HTMLRenderers/VideoRenderer.tsx:44-47).
      • When the user plays the video (and sets 2x speed) in the parent chat, PlaybackContext stores currentlyPlayingURL = videoUrl and currentRouteReportID = parentReportID.
      • When the user clicks Reply in thread, ReportsSplitNavigator (src/libs/Navigation/AppNavigator/createSplitNavigator/index.tsx:26) pushes the thread ReportScreen with nonTopScreenBehavior: 'freeze'.
        • On Native, ScreenFreezeWrapper (src/libs/Navigation/PlatformStackNavigation/createPlatformStackNavigatorComponent/ScreenFreezeWrapper/index.native.tsx:13,30-35) delays setFrozen(true) by FREEZE_DELAY_MS = 500 ms + requestAnimationFrame so transitional UI updates flush first; VideoPlayerPreview's blur listener (setIsThumbnail(true)) commits, unmounting the parent BaseVideoPlayer and running its cleanup (setCurrentlyPlayingURL(null) at src/components/VideoPlayer/BaseVideoPlayer.tsx:428-440).
        • On Web, ScreenFreezeWrapper (src/libs/Navigation/PlatformStackNavigation/createPlatformStackNavigatorComponent/ScreenFreezeWrapper/index.tsx:108-131) sets frozen = true in useLayoutEffect, suspending the covered parent ReportScreen inside <Freeze freeze={true}> before React Navigation's blur useEffect listener (src/components/VideoPlayerPreview/index.tsx:119-121) can commit setIsThumbnail(true). Consequently, the parent BaseVideoPlayer remains mounted in the frozen tree and never clears currentlyPlayingURL (and PlaybackContext's route effect at src/components/VideoPlayerContexts/PlaybackContext/index.tsx:107-134 also preserves state because getCurrentRouteReportID resolves the thread's ancestor attachment back to parentReportID and mountedVideoPlayersRef still contains videoUrl). The same state retention occurs on wide layouts when a thread opens in RHP while the parent screen remains visible.
    2. VideoPlayerPreview initializes prevPlaybackKey to the already-active playbackKey and handleOnPress never transitions isThumbnail when PlaybackContext state is unchanged:

      • In src/components/VideoPlayerPreview/index.tsx:62,112-131:
        const [isThumbnail, setIsThumbnail] = useState(true);
        ...
        const handleOnPress = () => {
            updateCurrentURLAndReportID(videoUrl, report, reportID);
            if (isSmallScreenWidth) {
                onShowModalPress();
            }
        };
        ...
        const playbackKey = `${currentlyPlayingURL}|${currentRouteReportID}|${videoUrl}|${reportID}|${isOnSearch}`;
        const [prevPlaybackKey, setPrevPlaybackKey] = useState(playbackKey);
        if (prevPlaybackKey !== playbackKey) {
            setPrevPlaybackKey(playbackKey);
            const isFocused = doesUserRemainOnFirstRenderRoute();
            if (videoUrl === currentlyPlayingURL && reportID === currentRouteReportID && isFocused) {
                setIsThumbnail(false);
            }
        }
      • When the thread's VideoPlayerPreview mounts, currentlyPlayingURL is already videoUrl and currentRouteReportID is already parentReportID, so prevPlaybackKey initializes to the exact active playbackKey while isThumbnail initializes to true.
      • Clicking Play in the thread calls updateCurrentURLAndReportID(videoUrl, report, parentReportID), which writes the exact same currentlyPlayingURL and currentRouteReportID. Both useState setters bail out (Object.is), playbackKey never changes (prevPlaybackKey !== playbackKey stays false), and handleOnPress does not call setIsThumbnail(false) when !isSmallScreenWidth.
    3. Hidden-player audio leak when the parent screen freezes mid-playback:

      • Because ScreenFreezeWrapper suspends the parent ReportScreen on Web before setIsThumbnail(true) can unmount the parent BaseVideoPlayer, if the parent video is still playing when the user opens the thread, VideoPlayerPreview's blur listener (line 120) never pauses it, updateCurrentURLAndReportID (src/components/VideoPlayerContexts/PlaybackContext/index.tsx:46-48) skips video.pause() because url === currentlyPlayingURLRef.current, and updateCurrentVideoPlayerRefs (src/components/VideoPlayerContexts/PlaybackContext/usePlaybackContextVideoRefs.ts:38-41) overwrites currentVideoPlayerRef.current with the thread player's ref without pausing the previous player instance—leaving the frozen parent <video> playing simultaneously in the background.

    What changes do you think we should make in order to solve the problem?

    1. Transition isThumbnail on wide-screen press and pause active playback on route blur in src/components/VideoPlayerPreview/index.tsx:

      • Destructure pauseVideo from usePlaybackActionsContext().
      • In handleOnPress, explicitly call setIsThumbnail(false) when !isSmallScreenWidth so clicking the thumbnail Play button always mounts VideoPlayer even when currentlyPlayingURL and currentRouteReportID already match videoUrl and reportID (once mounted, BaseVideoPlayer registers via shareVideoPlayerElements, updating originalParent and currentVideoPlayerRef, which triggers VideoPopoverMenuContext.tsx:45-53 to apply the stored 2x currentPlaybackSpeed):
        const handleOnPress = () => {
            updateCurrentURLAndReportID(videoUrl, report, reportID);
            if (isSmallScreenWidth) {
                onShowModalPress();
            } else {
                setIsThumbnail(false);
            }
        };
      • In the navigation.addListener('blur', ...) effect, imperatively pause via pauseVideo() when this preview owns the active inline player and we are not opening the attachment modal (!isOnAttachmentRoute()), ensuring a ScreenFreezeWrapper-suspended parent <video> stops immediately even though its React state re-render is frozen until unfreeze:
        const isActiveInlinePlayerRef = useRef(false);
        isActiveInlinePlayerRef.current = !isThumbnail && videoUrl === currentlyPlayingURL && reportID === currentRouteReportID;
        
        useEffect(() => {
            return navigation.addListener('blur', () => {
                if (isOnAttachmentRoute()) {
                    return;
                }
                if (isActiveInlinePlayerRef.current) {
                    pauseVideo();
                }
                setIsThumbnail(true);
            });
        }, [navigation, pauseVideo]);
    2. Pause any previous distinct VideoPlayer instance before swapping refs in src/components/VideoPlayerContexts/PlaybackContext/usePlaybackContextVideoRefs.ts:

      • In updateCurrentVideoPlayerRefs (lines 38-41), if currentVideoPlayerRef.current && currentVideoPlayerRef.current !== playerRef, pause the outgoing player before overwriting currentVideoPlayerRef.current:
        const updateCurrentVideoPlayerRefs: PlaybackContextVideoRefs['updateRefs'] = (playerRef, viewRef) => {
            if (currentVideoPlayerRef.current && currentVideoPlayerRef.current !== playerRef) {
                currentVideoPlayerRef.current.pause();
            }
            currentVideoPlayerRef.current = playerRef;
            currentVideoViewRef.current = viewRef;
        };
        This guarantees two non-shared BaseVideoPlayer instances for the same URL (such as a frozen parent screen + thread screen, or central pane + RHP) can never play simultaneously.
    3. Add unit tests in a new tests/unit/VideoPlayerPreviewTest.tsx file:

      • Verify that when VideoPlayerPreview mounts on a wide screen (isSmallScreenWidth = false) while PlaybackContext already holds currentlyPlayingURL === videoUrl and currentRouteReportID === reportID, pressing the thumbnail transitions isThumbnail to false and renders VideoPlayer.
      • Verify that firing the navigation blur event (when not on ROUTES.REPORT_ATTACHMENTS) calls pauseVideo() when the preview is the active inline player and resets isThumbnail to true.
      • Verify that updateCurrentVideoPlayerRefs pauses a previously registered distinct VideoPlayer instance when registering a new instance for the same video URL.

    What alternative solutions did you explore? (Optional)

    • Initializing prevPlaybackKey to null so the render-phase prevPlaybackKey !== playbackKey check runs on initial mount: Rejected because opening a thread (or scrolling a second occurrence into view) while currentlyPlayingURL === videoUrl would immediately replace the thumbnail and auto-play the video in the thread header without the user clicking Play, even when the user only opened the thread to type a reply.
    • Adding isChatThread(report) && findURLInReportOrAncestorAttachments(...) inside VideoPlayerPreview: Unnecessary and ineffective here because AncestorReportActionItem already passes parentReport.reportID (isChatThread(report) === false) to VideoPlayerPreview, and for a video posted directly inside a thread (or nested thread), findURLInReportOrAncestorAttachments already returns that thread's own reportID matching reportID.
  15. FitseTLT commented on Nov 17, 2026

    @FitseTLT
    Contributor

    REviewing this week

  16. expensify-chore-bot commented on Nov 20, 2026

    @expensify-chore-bot

    @FitseTLT Whoops! This issue is 2 days overdue. Let's get this updated quick!

  17. FitseTLT commented on Nov 20, 2026

    @FitseTLT
    Contributor

    Not overdue

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

Metadata

Metadata

Assignees

Labels

BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions