You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Web - Tab name shows the title of expense details page after closing the report #86087
Version Number: 9.3.42-0 Reproducible in staging?: Yes Reproducible in production?: No If this was caught during regression testing, add the test name, ID and link from BrowserStack:#85473 Email or phone of affected tester (no customers):skdpmoskpskspskd@gmail.com Issue reported by: Applause Internal Team Bug source: Exploratory - Significant User Experience Deterioration Device used: Mac 26.2 / Chrome App Component: Money Requests
Action Performed:
1 .Go to staging.new.expensify.com
2. Go to workspace chat.
3. Create two expenses.
4. Open the report.
5. Open any expense.
6. Close the RHP.
Expected Result:
Tab name will no longer show the title of expense details page.
Actual Result:
Tab name still shows the title of expense details page after closing the report.
👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:
Identify the pull request that introduced this issue and revert it.
Classification: Frontend bug Causing PR: #85473 - "Remove useDocumentTitle cleanup to fix tab title race condition" by @MelvinBot (High confidence) Related Issues: This is a regression from the fix for #85352
Recommendation: REVERT
PR #85473 removed the cleanup function from the useDocumentTitle hook that was clearing the document title when a screen lost focus. While this fixed a race condition where titles were being cleared too early, it introduced the opposite problem: titles now persist after navigating away from a screen.
When you close the expense detail RHP, the screen loses focus but the document title is never cleared, causing it to remain visible in the browser tab instead of reverting to the underlying page's title.
Labels: Keeping DeployBlockerCash - this is a frontend App bug that requires reverting or fixing PR #85473
📋 Detailed Analysis
Evidence
Bug is reproducible ONLY on staging (v9.3.42-0), NOT on production
useFocusEffect(useCallback(()=>{setPageTitle(title);// No cleanup - title persists after navigation},[title]),);
Confirmed the current code in src/hooks/useDocumentTitle.ts has no cleanup function, matching the change from PR #85473.
Root Cause
PR #85473 was attempting to fix issue #85352 where document titles were being cleared prematurely due to a race condition with async title updates. The fix removed the cleanup function entirely, assuming that "each page simply sets its own title on focus."
However, this assumption breaks for RHP (Right Hand Panel) screens. When you:
Open an expense detail in the RHP → the RHP screen sets its title
Close the RHP → the RHP screen loses focus but never clears its title
The underlying page (workspace chat) does not re-set its title because it never lost focus
Result: The expense detail title persists in the browser tab
The fix needs to be more sophisticated - it should clear titles on blur, but do so in a way that doesn't race with the async title update pipeline.
Please re-state the problem that we are trying to solve in this issue.
After opening an expense detail in the RHP (Right Hand Panel) and then closing the RHP, the browser tab title still shows the expense detail page's title instead of reverting to the underlying page's title (e.g., the workspace chat name).
What is the root cause of that problem?
PR #85473 removed the cleanup function from the useDocumentTitle hook at src/hooks/useDocumentTitle.ts. Previously, the hook returned () => setPageTitle('') from useFocusEffect, which cleared the module-level currentPageTitle variable (in src/libs/UnreadIndicatorUpdater/updateUnread/index.ts:8) when a screen lost focus.
Without cleanup, here's what happens:
The underlying screen (e.g., workspace chat's ReportScreen) sets currentPageTitle to its title via useDocumentTitle
The RHP opens, pushing onto the root stack. The RHP expense detail screen (also a ReportScreen) calls setPageTitle("Expense Detail"), overwriting currentPageTitle
The RHP closes (popped from root stack). The expense detail screen unmounts, but since there's no cleanup function, currentPageTitle remains "Expense Detail"
The underlying screen's useFocusEffect should re-fire on regaining focus to restore its title. However, the focus/blur event propagation chain (root stack → split navigator → central pane navigator → ReportScreen) relies on a series of async React.useEffect hooks in @react-navigation/core/src/useFocusEvents.tsx, and the useFocusEffect callback has a guard (if (isFocused) { return; } at useFocusEffect.tsx:82) that skips execution if the screen was never properly blurred
The popstate listener (updateUnread/index.ts:51-53) and debounced triggerUnreadUpdate (UnreadIndicatorUpdater/index.ts:87-108) both call updateDocumentTitle(), but they only re-read the stale currentPageTitle — they don't know the correct page-specific title
The net result: currentPageTitle permanently holds the RHP screen's title, and no mechanism resets it.
What changes do you think we should make in order to solve the problem?
Restore a non-disruptive cleanup in useDocumentTitle that clears currentPageTitle without triggering updateDocumentTitle():
In src/libs/UnreadIndicatorUpdater/updateUnread/index.ts — add and export a clearPageTitle function:
function clearPageTitle() {
currentPageTitle = '';
}
This resets the module variable silently, without queuing a setTimeout to update document.title.
In src/hooks/useDocumentTitle.ts — restore the cleanup using clearPageTitle:
Why this avoids the original race condition (issue #85352): The original cleanup called setPageTitle('') which triggered updateDocumentTitle() → setTimeout(() => { document.title = CONFIG.SITE_TITLE }). This async update could flash "New Expensify" if it executed between the cleanup and the new screen's title being set. By contrast, clearPageTitle() only clears the variable synchronously — no setTimeout is queued, so no "New Expensify" flash can occur.
Why this fixes the bug: When the RHP's expense detail screen unmounts, its cleanup clears currentPageTitle. The underlying screen's useFocusEffect then fires and sets the correct title. Even if the focus event doesn't propagate correctly, the next updateDocumentTitle() call (from popstate or triggerUnreadUpdate) will fall back to CONFIG.SITE_TITLE instead of showing a stale expense detail title.
What alternative solutions did you explore? (Optional)
Title stack approach: Maintain a stack of titles, pushing on focus and popping on blur. More robust but adds unnecessary complexity for what is essentially a cleanup oversight.
Navigation state listener: Update the title in the onStateChange handler in NavigationRoot.tsx. This would require mapping routes to titles, which duplicates the per-screen title logic.
Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, @MelvinBot <your feedback> to refine this analysis, or explain why you are rejecting Melvin's proposal.
👋 I've created a draft PR implementing the proposed fix: #86142
Instead of a straight revert (which would re-introduce the "New Expensify" title flash from #85352), this PR adds a new clearPageTitle() function that resets the module-level currentPageTitle variable synchronously without triggering updateDocumentTitle(). The useDocumentTitle hook's cleanup now calls clearPageTitle() instead of setPageTitle(''), avoiding the async setTimeout that caused the flash.
This should fix both issues simultaneously — the stale RHP title (this issue) and the title flash (#85352).
Please mark it as "Ready for review" when it is ready for review.
This issue has not been updated in over 15 days. @yuwenmemon eroding to Monthly issue.
P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!
Activity
melvin-bot commentedon Mar 23, 2026
You have been assigned to this deploy blocker because you recently merged this PR: #85473
melvin-bot commentedon Mar 23, 2026
💬 A slack conversation has been started in #expensify-open-source
github-actions commentedon Mar 23, 2026
👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:
OSBotify commentedon Mar 23, 2026
🔍 Investigation Summary
Classification: Frontend bug
Causing PR: #85473 - "Remove useDocumentTitle cleanup to fix tab title race condition" by @MelvinBot (High confidence)
Related Issues: This is a regression from the fix for #85352
Recommendation: REVERT
PR #85473 removed the cleanup function from the
useDocumentTitlehook that was clearing the document title when a screen lost focus. While this fixed a race condition where titles were being cleared too early, it introduced the opposite problem: titles now persist after navigating away from a screen.When you close the expense detail RHP, the screen loses focus but the document title is never cleared, causing it to remain visible in the browser tab instead of reverting to the underlying page's title.
Labels: Keeping
DeployBlockerCash- this is a frontend App bug that requires reverting or fixing PR #85473📋 Detailed Analysis
Evidence
Verification
The bug behavior matches exactly what would happen after removing the cleanup function:
Before PR #85473:
After PR #85473:
Confirmed the current code in
src/hooks/useDocumentTitle.tshas no cleanup function, matching the change from PR #85473.Root Cause
PR #85473 was attempting to fix issue #85352 where document titles were being cleared prematurely due to a race condition with async title updates. The fix removed the cleanup function entirely, assuming that "each page simply sets its own title on focus."
However, this assumption breaks for RHP (Right Hand Panel) screens. When you:
The fix needs to be more sophisticated - it should clear titles on blur, but do so in a way that doesn't race with the async title update pipeline.
MelvinBot commentedon Mar 23, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
After opening an expense detail in the RHP (Right Hand Panel) and then closing the RHP, the browser tab title still shows the expense detail page's title instead of reverting to the underlying page's title (e.g., the workspace chat name).
What is the root cause of that problem?
PR #85473 removed the cleanup function from the
useDocumentTitlehook atsrc/hooks/useDocumentTitle.ts. Previously, the hook returned() => setPageTitle('')fromuseFocusEffect, which cleared the module-levelcurrentPageTitlevariable (insrc/libs/UnreadIndicatorUpdater/updateUnread/index.ts:8) when a screen lost focus.Without cleanup, here's what happens:
ReportScreen) setscurrentPageTitleto its title viauseDocumentTitleReportScreen) callssetPageTitle("Expense Detail"), overwritingcurrentPageTitlecurrentPageTitleremains"Expense Detail"useFocusEffectshould re-fire on regaining focus to restore its title. However, the focus/blur event propagation chain (root stack → split navigator → central pane navigator → ReportScreen) relies on a series of asyncReact.useEffecthooks in@react-navigation/core/src/useFocusEvents.tsx, and theuseFocusEffectcallback has a guard (if (isFocused) { return; }atuseFocusEffect.tsx:82) that skips execution if the screen was never properly blurredpopstatelistener (updateUnread/index.ts:51-53) and debouncedtriggerUnreadUpdate(UnreadIndicatorUpdater/index.ts:87-108) both callupdateDocumentTitle(), but they only re-read the stalecurrentPageTitle— they don't know the correct page-specific titleThe net result:
currentPageTitlepermanently holds the RHP screen's title, and no mechanism resets it.What changes do you think we should make in order to solve the problem?
Restore a non-disruptive cleanup in
useDocumentTitlethat clearscurrentPageTitlewithout triggeringupdateDocumentTitle():In
src/libs/UnreadIndicatorUpdater/updateUnread/index.ts— add and export aclearPageTitlefunction:This resets the module variable silently, without queuing a
setTimeoutto updatedocument.title.In
src/hooks/useDocumentTitle.ts— restore the cleanup usingclearPageTitle:Why this avoids the original race condition (issue #85352): The original cleanup called
setPageTitle('')which triggeredupdateDocumentTitle()→setTimeout(() => { document.title = CONFIG.SITE_TITLE }). This async update could flash "New Expensify" if it executed between the cleanup and the new screen's title being set. By contrast,clearPageTitle()only clears the variable synchronously — nosetTimeoutis queued, so no "New Expensify" flash can occur.Why this fixes the bug: When the RHP's expense detail screen unmounts, its cleanup clears
currentPageTitle. The underlying screen'suseFocusEffectthen fires and sets the correct title. Even if the focus event doesn't propagate correctly, the nextupdateDocumentTitle()call (frompopstateortriggerUnreadUpdate) will fall back toCONFIG.SITE_TITLEinstead of showing a stale expense detail title.What alternative solutions did you explore? (Optional)
onStateChangehandler inNavigationRoot.tsx. This would require mapping routes to titles, which duplicates the per-screen title logic.return () => setPageTitle('')): This would re-introduce the "New Expensify" flash from issue [Due for payment 2026-03-31] Tab name does not persist after changing section and back to the previous section #85352.Next Steps for Contributor+ team: Reply with
@MelvinBot implement thisto create a draft PR,@MelvinBot <your feedback>to refine this analysis, or explain why you are rejecting Melvin's proposal.yuwenmemon commentedon Mar 23, 2026
@MelvinBot implement this
MelvinBot commentedon Mar 23, 2026
🤖 Draft PR created: #86141
Please mark it as "Ready for review" when it is ready for review.
MelvinBot commentedon Mar 23, 2026
👋 I've created a draft PR implementing the proposed fix: #86142
Instead of a straight revert (which would re-introduce the "New Expensify" title flash from #85352), this PR adds a new
clearPageTitle()function that resets the module-levelcurrentPageTitlevariable synchronously without triggeringupdateDocumentTitle(). TheuseDocumentTitlehook's cleanup now callsclearPageTitle()instead ofsetPageTitle(''), avoiding the asyncsetTimeoutthat caused the flash.This should fix both issues simultaneously — the stale RHP title (this issue) and the title flash (#85352).
Please mark it as "Ready for review" when it is ready for review.
yuwenmemon commentedon Mar 23, 2026
Not a blocker since this is already "buggy" in production. We should move forward with the proper fix above, without needing the rush to CP
melvin-bot commentedon Apr 16, 2026
This issue has not been updated in over 15 days. @yuwenmemon eroding to Monthly issue.
P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!
melvin-bot commentedon Jun 12, 2026
@yuwenmemon, this Monthly task hasn't been acted upon in 6 weeks; closing.
If you disagree, feel encouraged to reopen it -- but pick your least important issue to close instead.