[$175] Attachment – Unable to Open Video in Thread Chat
If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] 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:
- Navigate to staging.new.expensify.com.
- Open the app.
- Send a video in any chat.
- Change the playback speed to 2x.
- Reply to the video to create a thread.
- 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
- [x] Windows: Chrome
- [x] MacOS: Chrome / Safari
Screenshots/Videos
https://github.com/user-attachments/assets/bd240e98-4440-4d13-8640-ed5adbf538d2
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~022120507355921793494
- Upwork Job ID: 2120507355921793494
- Last Price Increase: 2026-11-11
Issue Owner
Current Issue Owner: @deetergp
Triggered auto assignment to Contributor-plus team member for initial proposal review - @FitseTLT (External)
Job added to Upwork: https://www.upwork.com/jobs/~022120507355921793494
🤖 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.
| 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.![]() |
✅ |
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
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?
- In
src/components/AttachmentModal.tsxandsrc/components/ReportActionItem/AttachmentView.tsx:- Ensure
sourceandoriginalFileNameresolution 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.
- Ensure
- In
src/libs/actions/Report.ts(openReportAttachmentModal):- Pass the explicit
reportActionIDand parentreportIDso the video player receives the fully qualified authenticated attachment URL.
- Pass the explicit
What alternative solutions did you explore? (Optional)
Attempting to proxy attachment URLs without the auth token header, which fails for secure attachments.
Contributor details Your Expensify account email: [email protected] 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?
-
How the video preview is rendered inside the thread header (
00:08–00:14of the QA recording):- In a chat thread (e.g.
reportID = "487551176124257"created from parent chatreportID = "5409533764521432"),ReportActionItemParentAction(src/pages/inbox/report/ReportActionItemParentAction.tsx:61,123-144) usesuseAncestors(report, ...)to render an<AncestorReportActionItem>for each ancestor. getAncestors(src/libs/ReportUtils.ts:13117-13129) walks upparentReportIDand populatesancestor.reportwith the parent report (5409533764521432).AncestorReportActionItem(src/pages/inbox/report/AncestorReportActionItem.tsx:171-174) renders<ReportActionItem report={ancestorReport} action={ancestorReportAction} isThreadReportParentAction ... />, which passesreportID = ancestorReport.reportID("5409533764521432") down throughActionContentRouter→ChatMessageContent(AttachmentContext.Provider value={{reportID, type: CONST.ATTACHMENT_TYPE.REPORT}}) →VideoRenderer→VideoPlayerPreview(src/components/HTMLEngineProvider/HTMLRenderers/VideoRenderer.tsx:44-47).- Consequently, the
VideoPlayerPreviewinstance inside the thread view hasreportID = "5409533764521432"(the parent report ID where the attachment belongs).
- In a chat thread (e.g.
-
Why
prevPlaybackKeyinVideoPlayerPreviewignores the Play click in the thread:- Look at
VideoPlayerPreviewinsrc/components/VideoPlayerPreview/index.tsx:112-131(introduced whenuseEffectwas converted to a render-phaseplaybackKeycomparison 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,PlaybackContextsets:currentlyPlayingURL = videoUrlcurrentRouteReportID = "5409533764521432"
- When the user then clicks Reply in thread, the app navigates to the thread report (
487551176124257):- 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), callsfindURLInReportOrAncestorAttachments(report, url), finds the video in the parent report's actions, and returns"5409533764521432"(andisURLStillMountedis alsotruebecause the parent screen stays mounted in the stack). ThusPlaybackContextdoes not reset, leavingcurrentlyPlayingURL === videoUrlandcurrentRouteReportID === "5409533764521432". - When the thread screen mounts its own
VideoPlayerPreviewfor the parent action,isThumbnailinitializes touseState(true), andprevPlaybackKeyinitializes touseState(playbackKey)whereplaybackKeyis already:"${videoUrl}|5409533764521432|${videoUrl}|5409533764521432|false". - Because
prevPlaybackKey === playbackKeyon initial mount, theif (prevPlaybackKey !== playbackKey)block does not run on mount. - When the user clicks the Play button on the video thumbnail in the thread (
00:08–00:13),handleOnPresscallsupdateCurrentURLAndReportID(videoUrl, report, "5409533764521432"). That setscurrentlyPlayingURLto the exact samevideoUrlandcurrentRouteReportIDto the exact same"5409533764521432". - Neither
currentlyPlayingURLnorcurrentRouteReportIDchanges (playbackKeyis unchanged!), andhandleOnPressnever callssetIsThumbnail(false)directly on wide screens (!isSmallScreenWidth). As a result,isThumbnailstaystrueforever andBaseVideoPlayernever mounts!
- In
- Look at
What changes do you think we should make in order to solve the problem?
In src/components/VideoPlayerPreview/index.tsx:
- In
handleOnPress, when on a wide layout (!isSmallScreenWidth), directly setsetIsThumbnail(false)so pressing the thumbnail Play button always transitions the clickedVideoPlayerPreviewfrom thumbnail toVideoPlayereven whencurrentlyPlayingURLandcurrentRouteReportIDinPlaybackContextalready match thisvideoUrlandreportID(such as when opening a thread after playing the parent video, or returning to a blurred screen wherenavigation.addListener('blur')resetisThumbnailtotruewhileplaybackKeyremained unchanged):
const handleOnPress = () => {
updateCurrentURLAndReportID(videoUrl, report, reportID);
if (isSmallScreenWidth) {
onShowModalPress();
} else {
setIsThumbnail(false);
}
};
- Add a unit test in
tests/unit/VideoPlayerPreviewTest.tsxverifying that whenPlaybackContextalready holds matchingcurrentlyPlayingURL === videoUrlandcurrentRouteReportID === reportIDat the timeVideoPlayerPreviewmounts (or after a navigationblurevent resetsisThumbnailtotrue), pressing the thumbnail on a wide screen (isSmallScreenWidth = false) transitionsisThumbnailtofalseand rendersVideoPlayer.
What alternative solutions did you explore? (Optional)
- Initializing
prevPlaybackKeytonull(useState<string | null>(null)) so theif (prevPlaybackKey !== playbackKey)block also runs on mount: IfprevPlaybackKeystarted asnull, 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. SettingsetIsThumbnail(false)insidehandleOnPress(when!isSmallScreenWidth) keeps the thread header as a clean thumbnail on thread open and reliably mounts and playsVideoPlayer(inheriting the 2xcurrentPlaybackSpeedviaVideoPopoverMenuContext.tsx:45-53) the moment the user clicks Play.
— submitted with Antigravity on the contributor's behalf
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
Contributor details Your Expensify account email: [email protected] 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.
-
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,
currentRouteReportIDis set to the parent report's ID. -
However, the
VideoPlayerPreviewmounted inside the thread receivesreportIDas the thread's ownreportID. InVideoPlayerPreview/index.tsx:128-130:if (videoUrl === currentlyPlayingURL && reportID === currentRouteReportID && isFocused) { setIsThumbnail(false); }Because
reportID(thread report ID) does not matchcurrentRouteReportID(parent report ID), the condition evaluates tofalse. 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.
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
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:
-
reportIDmismatch between thread and normalized ancestor report inPlaybackContext:- In
PlaybackContext/index.tsx:58-65, whenupdateCurrentURLAndReportIDis called with a thread report (isChatThread(report)istrue),setCurrentRouteReportIDdoes not set the thread's own report ID. Instead, it resolves the ancestor report ID where the attachment originated viafindURLInReportOrAncestorAttachments(report, url):
As a result,const isReportAChatThread = isChatThread(report); const reportIDtoSet = isReportAChatThread ? (findURLInReportOrAncestorAttachments(report, url) ?? NO_REPORT_ID) : reportID; setCurrentRouteReportID(reportIDtoSet);currentRouteReportIDinPlaybackContextis set toparentReport.reportID. - However, in
VideoPlayerPreview/index.tsx:128-130, the component receivesreportIDas the thread's report ID (threadReport.reportID). It checks:
Becauseif (videoUrl === currentlyPlayingURL && reportID === currentRouteReportID && isFocused) { setIsThumbnail(false); }reportID(threadReport.reportID) does not equalcurrentRouteReportID(parentReport.reportID), this check evaluates tofalse.setIsThumbnail(false)is never called, leaving the video permanently trapped in thumbnail mode.
- In
-
handleOnPressfails to transitionisThumbnailand staleplaybackKeystate prevents re-evaluation:- In
VideoPlayerPreview/index.tsx:112-117:
On wide screens (const handleOnPress = () => { updateCurrentURLAndReportID(videoUrl, report, reportID); if (isSmallScreenWidth) { onShowModalPress(); } };!isSmallScreenWidth), clicking the thumbnail's play button is an explicit user intent to mount and play the video inline. However,handleOnPressdoes not callsetIsThumbnail(false)directly; it delegates thumbnail toggling solely to theprevPlaybackKey !== playbackKeyrender 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),
currentlyPlayingURLis alreadyvideoUrl, andcurrentRouteReportIDis alreadyparentReport.reportID. - When the user opens the thread and clicks the thumbnail,
updateCurrentURLAndReportID(videoUrl, report, reportID)setscurrentlyPlayingURLandcurrentRouteReportIDto the exact same values they already held. Consequently,playbackKeydoes not change (prevPlaybackKey !== playbackKeyevaluates tofalse), so the thumbnail state transition is never even triggered.
- In
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)inhandleOnPresswithout updating theplaybackKeycheck: While settingsetIsThumbnail(false)directly inhandleOnPressresolves the immediate user click, if playback is triggered externally or when navigating between related chats, the thumbnail would fail to activate becausereportID === currentRouteReportIDremains false for thread reports. Doing both ensures airtight reliability. - Normalizing
currentRouteReportIDinsideVideoPlayerPreviewprops: Passing the ancestor report ID intoVideoPlayerPreviewwould break downstream components likeVideoPlayer(src/components/VideoPlayer/index.tsx) anduseReportActionswhich require the realreportIDof the current screen to load comments and thread actions. ResolvingisMatchingReportwithinVideoPlayerPreviewpreserves the integrity ofreportID.
What automated tests can you add to prevent this from re-occurring?
In tests/unit/VideoPlayerPreviewTest.tsx:
- Verify that pressing the thumbnail on wide screen (
isSmallScreenWidth: false) setsisThumbnailtofalseand rendersVideoPlayer. - Verify that when
VideoPlayerPreviewis rendered inside a chat thread report (isChatThread(report) === true) andcurrentRouteReportIDinPlaybackContextmatches the parent report ID where the video originated,isMatchingReportresolves totrueand activates the player.
Contributor details
Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~0131dae36abcf59374
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
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?
-
Parent video in a thread header shares the parent
reportID, whileScreenFreezeWrapperon Web freezes the parent screen beforeBaseVideoPlayercan unmount and clearPlaybackContext:- Inside the thread screen,
ReportActionItemParentAction(src/pages/inbox/report/ReportActionItemParentAction.tsx:61,123-126) resolves ancestors viauseAncestorsand renders<AncestorReportActionItem report={ancestorReport} ... />(src/pages/inbox/report/AncestorReportActionItem.tsx:171-186), which passesreportID = ancestorReport.reportID(the parent chat'sreportID, not the thread'sreportID) down throughReportActionItem->ActionContentRouter->ChatMessageContent(AttachmentContext.Provideratsrc/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
2xspeed) in the parent chat,PlaybackContextstorescurrentlyPlayingURL = videoUrlandcurrentRouteReportID = parentReportID. - When the user clicks Reply in thread,
ReportsSplitNavigator(src/libs/Navigation/AppNavigator/createSplitNavigator/index.tsx:26) pushes the threadReportScreenwithnonTopScreenBehavior: 'freeze'.- On Native,
ScreenFreezeWrapper(src/libs/Navigation/PlatformStackNavigation/createPlatformStackNavigatorComponent/ScreenFreezeWrapper/index.native.tsx:13,30-35) delayssetFrozen(true)byFREEZE_DELAY_MS = 500ms +requestAnimationFrameso transitional UI updates flush first;VideoPlayerPreview'sblurlistener (setIsThumbnail(true)) commits, unmounting the parentBaseVideoPlayerand running its cleanup (setCurrentlyPlayingURL(null)atsrc/components/VideoPlayer/BaseVideoPlayer.tsx:428-440). - On Web,
ScreenFreezeWrapper(src/libs/Navigation/PlatformStackNavigation/createPlatformStackNavigatorComponent/ScreenFreezeWrapper/index.tsx:108-131) setsfrozen = trueinuseLayoutEffect, suspending the covered parentReportScreeninside<Freeze freeze={true}>before React Navigation'sbluruseEffectlistener (src/components/VideoPlayerPreview/index.tsx:119-121) can commitsetIsThumbnail(true). Consequently, the parentBaseVideoPlayerremains mounted in the frozen tree and never clearscurrentlyPlayingURL(andPlaybackContext's route effect atsrc/components/VideoPlayerContexts/PlaybackContext/index.tsx:107-134also preserves state becausegetCurrentRouteReportIDresolves the thread's ancestor attachment back toparentReportIDandmountedVideoPlayersRefstill containsvideoUrl). The same state retention occurs on wide layouts when a thread opens in RHP while the parent screen remains visible.
- On Native,
- Inside the thread screen,
-
VideoPlayerPreviewinitializesprevPlaybackKeyto the already-activeplaybackKeyandhandleOnPressnever transitionsisThumbnailwhenPlaybackContextstate 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
VideoPlayerPreviewmounts,currentlyPlayingURLis alreadyvideoUrlandcurrentRouteReportIDis alreadyparentReportID, soprevPlaybackKeyinitializes to the exact activeplaybackKeywhileisThumbnailinitializes totrue. - Clicking Play in the thread calls
updateCurrentURLAndReportID(videoUrl, report, parentReportID), which writes the exact samecurrentlyPlayingURLandcurrentRouteReportID. BothuseStatesetters bail out (Object.is),playbackKeynever changes (prevPlaybackKey !== playbackKeystaysfalse), andhandleOnPressdoes not callsetIsThumbnail(false)when!isSmallScreenWidth.
- In
-
Hidden-player audio leak when the parent screen freezes mid-playback:
- Because
ScreenFreezeWrappersuspends the parentReportScreenon Web beforesetIsThumbnail(true)can unmount the parentBaseVideoPlayer, if the parent video is still playing when the user opens the thread,VideoPlayerPreview'sblurlistener (line 120) never pauses it,updateCurrentURLAndReportID(src/components/VideoPlayerContexts/PlaybackContext/index.tsx:46-48) skipsvideo.pause()becauseurl === currentlyPlayingURLRef.current, andupdateCurrentVideoPlayerRefs(src/components/VideoPlayerContexts/PlaybackContext/usePlaybackContextVideoRefs.ts:38-41) overwritescurrentVideoPlayerRef.currentwith the thread player's ref without pausing the previous player instance—leaving the frozen parent<video>playing simultaneously in the background.
- Because
What changes do you think we should make in order to solve the problem?
-
Transition
isThumbnailon wide-screen press and pause active playback on routeblurinsrc/components/VideoPlayerPreview/index.tsx:- Destructure
pauseVideofromusePlaybackActionsContext(). - In
handleOnPress, explicitly callsetIsThumbnail(false)when!isSmallScreenWidthso clicking the thumbnail Play button always mountsVideoPlayereven whencurrentlyPlayingURLandcurrentRouteReportIDalready matchvideoUrlandreportID(once mounted,BaseVideoPlayerregisters viashareVideoPlayerElements, updatingoriginalParentandcurrentVideoPlayerRef, which triggersVideoPopoverMenuContext.tsx:45-53to apply the stored2xcurrentPlaybackSpeed):const handleOnPress = () => { updateCurrentURLAndReportID(videoUrl, report, reportID); if (isSmallScreenWidth) { onShowModalPress(); } else { setIsThumbnail(false); } }; - In the
navigation.addListener('blur', ...)effect, imperatively pause viapauseVideo()when this preview owns the active inline player and we are not opening the attachment modal (!isOnAttachmentRoute()), ensuring aScreenFreezeWrapper-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]);
- Destructure
-
Pause any previous distinct
VideoPlayerinstance before swapping refs insrc/components/VideoPlayerContexts/PlaybackContext/usePlaybackContextVideoRefs.ts:- In
updateCurrentVideoPlayerRefs(lines 38-41), ifcurrentVideoPlayerRef.current && currentVideoPlayerRef.current !== playerRef, pause the outgoing player before overwritingcurrentVideoPlayerRef.current:
This guarantees two non-sharedconst updateCurrentVideoPlayerRefs: PlaybackContextVideoRefs['updateRefs'] = (playerRef, viewRef) => { if (currentVideoPlayerRef.current && currentVideoPlayerRef.current !== playerRef) { currentVideoPlayerRef.current.pause(); } currentVideoPlayerRef.current = playerRef; currentVideoViewRef.current = viewRef; };BaseVideoPlayerinstances for the same URL (such as a frozen parent screen + thread screen, or central pane + RHP) can never play simultaneously.
- In
-
Add unit tests in a new
tests/unit/VideoPlayerPreviewTest.tsxfile:- Verify that when
VideoPlayerPreviewmounts on a wide screen (isSmallScreenWidth = false) whilePlaybackContextalready holdscurrentlyPlayingURL === videoUrlandcurrentRouteReportID === reportID, pressing the thumbnail transitionsisThumbnailtofalseand rendersVideoPlayer. - Verify that firing the navigation
blurevent (when not onROUTES.REPORT_ATTACHMENTS) callspauseVideo()when the preview is the active inline player and resetsisThumbnailtotrue. - Verify that
updateCurrentVideoPlayerRefspauses a previously registered distinctVideoPlayerinstance when registering a new instance for the same video URL.
- Verify that when
What alternative solutions did you explore? (Optional)
- Initializing
prevPlaybackKeytonullso the render-phaseprevPlaybackKey !== playbackKeycheck runs on initial mount: Rejected because opening a thread (or scrolling a second occurrence into view) whilecurrentlyPlayingURL === videoUrlwould 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(...)insideVideoPlayerPreview: Unnecessary and ineffective here becauseAncestorReportActionItemalready passesparentReport.reportID(isChatThread(report) === false) toVideoPlayerPreview, and for a video posted directly inside a thread (or nested thread),findURLInReportOrAncestorAttachmentsalready returns that thread's ownreportIDmatchingreportID.
REviewing this week
@FitseTLT Whoops! This issue is 2 days overdue. Let's get this updated quick!
Not overdue
@MelvinBot Do you have a proposal for this?
Proposal
This aligns with the minimal fix in HindsightWise’s proposal.
What is the root cause of that problem?
Desktop Play depends on the shared playback selection changing before it replaces the thumbnail with a player. If the same video/report is already selected when the thread preview mounts, clicking Play writes identical values, so the thumbnail never changes.
Confidence: The unchanged-selection defect is confirmed in code; whether selection survives navigation in the reported reproduction remains unverified.
Code evidence and competing explanations
- The preview initializes as a thumbnail. Its desktop click handler only updates selection; activation requires a changed playback key.
- The thread header receives the ancestor report, so changing attachment authentication or broadly relaxing report-ID matching is not justified.
- Importantly, parent-player cleanup can clear selection. Runtime confirmation must establish that selection remains unchanged at the failed click.
- Playback speed is absent from the activation key, so this explanation predicts possible failure at 1x too.
What changes do you think we should make in order to solve the problem?
For the confirmed unchanged-selection case, explicitly activate the clicked preview on wide screens by setting its thumbnail state to false in the click handler. Preserve small-screen modal behavior.
Add regression coverage for:
- Matching selection at mount: no autoplay, but Play mounts the player.
- Clicking again after blur resets the thumbnail.
- Ordinary playback and small-screen modal behavior.
Before accepting this as the issue’s solution, confirm the retained-selection condition on web at 1x and 2x, and verify that switching to the thread leaves only one audible player.
What alternative solutions did you explore? (Optional)
Avoid activating matching previews automatically on mount: opening a thread should not start playback. Do not bundle global pause/ref-management changes without reproducing overlapping audio.
Next Steps for Contributor+ team: Confirm the runtime condition above before requesting implementation; if parent cleanup clears selection before the failed click, this proposal does not explain that failure.
Melvin's proposal LGTM
🎀 👀 🎀 C+ reviewed
Triggered auto assignment to @deetergp, see https://stackoverflow.com/c/expensify/questions/7972 for more details.
Run with it @FitseTLT 🚀
@MelvinBot implement