Add non-disruptive cleanup to useDocumentTitle hook#86142
Open
Add non-disruptive cleanup to useDocumentTitle hook#86142
Conversation
Instead of reverting the cleanup removal entirely, add a new clearPageTitle()
function that resets the module-level currentPageTitle variable without
triggering updateDocumentTitle(). This avoids the "New Expensify" title flash
from the original cleanup (setPageTitle('')) while still clearing the stale
title when the RHP closes.
Co-authored-by: Yuwen Memon <yuwenmemon@users.noreply.github.com>
This was referenced Mar 23, 2026
Codecov Report❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.
|
|
@thesahindia Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
trjExpensify
approved these changes
Mar 24, 2026
Contributor
trjExpensify
left a comment
There was a problem hiding this comment.
Seems like a straightforward bug fix to prevent flashing. 👍
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation of Change
PR #85473 removed the cleanup function from the
useDocumentTitlehook to fix a "New Expensify" title flash (#85352). However, removing the cleanup entirely caused the browser tab title to show stale RHP page titles after closing the panel.This PR takes a different approach: instead of calling
setPageTitle('')on cleanup (which queues an asyncupdateDocumentTitle()viasetTimeoutand causes the flash), we introduce a newclearPageTitle()function that only resets the module-levelcurrentPageTitlevariable synchronously — nosetTimeoutis queued, so no "New Expensify" flash can occur.When the RHP unmounts, the cleanup clears the stale title. The underlying screen's
useFocusEffectthen 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.Fixed Issues
$ #86087
PROPOSAL: #86087 (comment)
Tests
Offline tests
N/A — this change only affects browser tab title behavior, which is not relevant offline.
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
N/A — web-only change (browser tab title)
Android: mWeb Chrome
N/A — web-only change (browser tab title)
iOS: Native
N/A — web-only change (browser tab title)
iOS: mWeb Safari
N/A — web-only change (browser tab title)
MacOS: Chrome / Safari
N/A — web-only change (browser tab title)