Repository navigation
Description
If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.
Version Number: v9.5.13-3
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://test-management.browserstack.com/projects/2219752/test-runs/79209900/folder/13176686/44007893/1871926840?sort=%2Bidentifier
Email or phone of affected tester (no customers): N/A
Issue reported by: Applause Internal Team
Bug source: Regression TC Execution
Device used: Windows 11 Chrome
App Component: Chat Report View
Action Performed:
Preconditions:
- Create 2 workspaces
- Delete 1 workspace
- Open https://staging.new.expensify.com/
- Navigate to Spend > Reports
- Click FAB
- Click 'Create reports'
- Comment on the empty report
- Right lick on the comment
- Click on 'Edit comment'
Expected Result:
Verify that the input of the message whose element you have selected is in focus
Actual Result:
The input compose is not focused
Workaround:
Unknown
Platforms:
- Android: App
- Android: mWeb Chrome
- iOS: App
- iOS: mWeb Safari
- iOS: mWeb Chrome
- Windows: Chrome
- MacOS: Chrome Safari
Screenshots/Videos
Bug7289481_1792305520541.bandicam_2026-10-18_13-29-40-872.mp4
Applause Internal Information
Exported by: Svetlana Lazutkina
Bug ID: 7289481
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~022112190878495307640
- Upwork Job ID: 2112190878495307640
- Last Price Increase: 2026-11-07
Issue Owner
Current Issue Owner: @wildan-mMetadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNo status
Activity
applause-bot commentedon Oct 19, 2026
While Applause doesn't embed attachments for this bug, here are the links for quick view:
https://platform.applause.com/services/links/v1/external/d8325cff8e01e345bb4135539346d6690f60b2b78e100510d034efea4654e9e8
MelvinBot commentedon Oct 19, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
After you delete a workspace, the "Edit comment" input does not get focus on a report opened from Spend > Reports.
What is the root cause of that problem?
Deleting a workspace leaves behind a "ready to focus" promise that never resolves. Every delayed composer focus then waits on it forever.
closeModal()removes it from the global modal stack while it is still visible. This unmounts the modal instead of hiding it.BaseModalcallshideModal, but neverComposerFocusManager.setReadyToFocus(id). Only the visible→hidden path resolves the promise. So the modal's entry stays inpromiseMap, unresolved.focusComposerWithDelaywaits onComposerFocusManager.isReadyToFocus()with no id. With no id, it reads the last key inpromiseMap. Later modals add and remove their own keys, so the leaked entry ends up last again.ReportActionItemMessageEditsetsautoFocus={!shouldUseNarrowLayout}, which isfalsethere. Its only focus path is the delayed focus on mount, which never runs.Inbox chats on wide web still work because
autoFocusistruethere. The empty report doesn't matter. The deleted workspace is the trigger.Code references
setReadyToFocus: BaseModal.tsx:197-206, compared with the dismiss path at BaseModal.tsx:173-176hideModalwaits on the same unresolved promise: BaseModal.tsx:152isReadyToFocus()with no id uses the last key: ComposerFocusManager.ts:189-231What changes do you think we should make in order to solve the problem?
In
BaseModal, when the modal unmounts while still visible, also callComposerFocusManager.setReadyToFocus(uniqueModalId)in the unmount cleanup. This fixes every global modal that closes while visible, not only delete-workspace.What alternative solutions did you explore? (Optional)
ConfirmModalWrapperhide itself first (isVisible=false), then pop the stack inonModalHide, instead of unmounting while visible.isReadyToFocus()wait infocusComposerWithDelay, so one leaked promise can't block focus for the whole session.Confidence and verification
Confidence: Medium. The code path is confirmed. I could not reproduce it at runtime: on web, the test tool can't right-click, so it never reached "Edit comment". The empty report was created and the comment posted fine.
To confirm, test edit-comment in a fresh session where no workspace was deleted. This theory says it should focus there. In a session where a workspace was deleted, a non-empty report from Spend > Reports should also fail.
Next Steps for Contributor+ team:
To accept:
@MelvinBot implement [this](https://github.com/Expensify/App/issues/104360)to create a draft PR.To refine:
@MelvinBot <your feedback>To reject: Explain why you are rejecting Melvin's proposal.
view run · view recording
melvin-bot commentedon Oct 19, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @parasharrajat (
External)[-]Web-Chat- Edit comment input is not focused[/-][+][$175] Web-Chat- Edit comment input is not focused[/+]melvin-bot commentedon Oct 19, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022112190878495307640
camesenin commentedon Oct 19, 2026
melvin-bot commentedon Oct 19, 2026
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
azhumide commentedon Oct 19, 2026
Contributor details
Your Expensify account email: azhumide@gmail.com
Upwork Profile Link: https://www.upwork.com/freelancers/~01096eb540e2a8e9a5
Proposal
Please re-state the problem that we are trying to solve in this issue.
On Web, after deleting a workspace (or when any modal unmounts while visible), right-clicking a message in a report opened from Spend > Reports and selecting "Edit comment" fails to focus the edit comment composer input.
What is the root cause of that problem?
A leaked unresolved promise in
ComposerFocusManager:When a modal opens (
onModalWillShow),BaseModal.tsx:359callssaveFocusState(), which callsComposerFocusManager.resetReadyToFocus(uniqueModalId)(BaseModal.tsx:133). This registers a pending promise inComposerFocusManager.promiseMap(src/libs/ComposerFocusManager.ts:189-198).In normal dismiss flows,
handleDismissModal()runs inuseEffectwhen!isVisible && wasVisible(BaseModal.tsx:174-176), invokingComposerFocusManager.setReadyToFocus(uniqueModalId)which resolves and deletes the entry frompromiseMap.However, when a modal unmounts directly while still visible (such as during
DeleteWorkspaceFlowwhencloseModalpops the modal stack while in a loading state):The unmount effect runs (
BaseModal.tsx:197-206):This calls
hideModalCallbackRef.current?.(true), which triggershideModal()and callsComposerFocusManager.refocusAfterModalFullyClosed(uniqueModalId, restoreFocusType)(BaseModal.tsx:152).However,
handleDismissModal()is never called because the!isVisible && wasVisibleupdate effect never executes when unmounting directly.As a result:
uniqueModalIdremains permanently inpromiseMapwith an unresolved promise.ReportActionItemMessageEdit.tsx:160callsfocusComposerWithDelay(composerRef.current)(true).src/libs/focusComposerWithDelay/index.ts:57, it awaitsPromise.all([ComposerFocusManager.isReadyToFocus(), isWindowReadyToFocus()]).ComposerFocusManager.isReadyToFocus()(called without arguments) invokesgetTopmostModalId(), which returns the leaked modal ID frompromiseMap.awaithangs indefinitely, completely blocking composer focus.Flaws in existing proposals:
ComposerFocusManager.cameseninproposed:[handleDismissModal]as a dependency on an unmount cleanup effect is a critical bug: the cleanup function fires on every render wherehandleDismissModalchanges, resolving the focus promise prematurely while the modal is still mounted and open.What changes do you think we should make in order to solve the problem?
src/components/Modal/BaseModal.tsx:uniqueModalIdin a ref (or capture it cleanly) and invokeComposerFocusManager.setReadyToFocusinside the unmount cleanup effect:src/libs/ComposerFocusManager.ts(Defense-in-depth):getTopmostModalId(), verify that the returned modal ID corresponds to an active modal; if the map holds dangling keys with no active modals, prune them soisReadyToFocus()never hangs indefinitely.What specific scenarios should we cover in automated tests?
In
tests/ui/BaseModalTest.tsx:BaseModalwithisVisible={true}.ComposerFocusManager.isReadyToFocus()resolves immediately after unmount instead of hanging unresolved.melvin-bot commentedon Oct 19, 2026
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
khizzcr7 commentedon Oct 19, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
After deleting a workspace, opening a report from Spend > Reports and right-clicking a comment to "Edit comment" does not focus the comment input on web.
What is the root cause of that problem?
Deleting the workspace leaves a never-resolving "ready to focus" promise behind, and every delayed composer focus after that waits on it forever:
closeModal()while it is still in its loading state, which unmounts the modal instead of dismissing it.BaseModal'shandleDismissModal(which callsComposerFocusManager.setReadyToFocus(uniqueModalId)) only runs on the visible-to-hidden path (isVisible && wasVisible). The unmount cleanup callshideModal, which only callsComposerFocusManager.refocusAfterModalFullyClosed- that waits onisReadyToFocus(id)and never resolves the promise itself. So the modal's entry leaks inpromiseMap.focusComposerWithDelaycallsComposerFocusManager.isReadyToFocus()with no id, which reads the last key inpromiseMapviagetTopmostModalId(). The leaked entry ends up last again, so delayed focus never fires.ReportActionItemMessageEditsetsautoFocus={!shouldUseNarrowLayout}which isfalsethere, so the delayed focus on mount is its only focus path - and it never runs.Inbox chats on wide web still work because
autoFocusistruethere. The empty report and the deleted workspace are just the trigger, not the cause.What changes do you think we should make in order to solve the problem?
In
BaseModal, when the modal unmounts while it is still visible, also callComposerFocusManager.setReadyToFocus(uniqueModalId)in the unmount cleanup. This fixes every global modal that closes while visible, not only the delete-workspace flow.What alternative solutions did you explore?
ConfirmModalWrapperhide itself first (isVisible=false), then pop the modal stack inonModalHide, instead of unmounting while visible.isReadyToFocus()wait infocusComposerWithDelay, so one leaked promise cannot block focus for the whole session.What will I verify?
64 remaining items
RajGahoi commentedon Nov 12, 2026
Contributor details
Your Expensify account email: gahoiraj01@gmail.com
Upwork Profile Link: https://www.upwork.com/freelancers/~014898525b9c53fc32
Proposal
Please re-state the problem that we are trying to solve in this issue.
On Web, after deleting a workspace and subsequently opening a report in the RHP (e.g. via Spend > Reports > Create report), posting a comment, and clicking "Edit comment", the edit message composer does not receive input focus.
What is the root cause of that problem?
Two factors interact to trigger this bug:
Unresolved
readyToFocuspromise leak inComposerFocusManagerupon unmounting visible modals:BaseModal.tsxregisters a pending promise inComposerFocusManager.resetReadyToFocus(uniqueModalId).DeleteWorkspaceFlow.tsx, the confirm modal remains in a loading state (isConfirmLoading: true) until the deletion completes, at which pointcloseModal()directly removes the modal fromModalContext.BaseModalwhileisVisibleis stilltrue.BaseModal's unmount cleanup callshideModalCallbackRef.current?.(true), it does not callComposerFocusManager.setReadyToFocus(uniqueModalId). (Normal resolution only happens whenisVisibletransitions fromtruetofalseor duringonDismiss).uniqueModalIdis left permanently inComposerFocusManager.promiseMapwith an unresolved promise.Delayed composer focus hangs forever in RHP:
ReportActionItemMessageEdit.tsx, the input specifiesautoFocus={!shouldUseNarrowLayout}. In RHP,isInNarrowPaneModalistrue, makingshouldUseNarrowLayouttrue, which disablesautoFocus.focusComposerWithDelay(composerRef.current)(true)on mount.focusComposerWithDelayawaitsComposerFocusManager.isReadyToFocus(). Without a modal ID passed,isReadyToFocus()defaults togetTopmostModalId(), which returns the leaked promise from the unmounted delete-workspace modal.focusComposerWithDelayawaits indefinitely, andcomposerRef.current.focus()is never executed.What changes do you think we should make in order to solve the problem?
In
src/components/Modal/BaseModal.tsx:useEffect(() => () => { ... }, [])), ensure that ifshouldCallHideModalOnUnmount.currentistrue(i.e. the modal unmounted while visible),ComposerFocusManager.setReadyToFocus(uniqueModalId)is called before or alongsidehideModalCallbackRef.current?.(true).promiseMap, preventing leaked promises from locking future delayed composer focuses.In
src/libs/ComposerFocusManager.ts(Defensive guard):isReadyToFocus, if all active modals are closed or no matching modal is currently active, ensure it does not hang on orphaned promises.What alternative solutions did you explore? (Optional)
focusComposerWithDelay: This only masks the leak by introducing an artificial delay before focus occurs. ResolvingsetReadyToFocusinBaseModal's unmount cleanup handles the leak at its origin.autoFocus={true}inReportActionItemMessageEdit: Does not fix the underlying leak inComposerFocusManager, which would continue to affect any other delayed focus consumer in the app after an unmounted modal.What specific scenarios should we cover in automated tests?
tests/ui/BaseModalTest.tsx(orComposerFocusManagerTest.ts):BaseModalwithisVisible={true}.BaseModaldirectly whileisVisibleis stilltrue.ComposerFocusManager.isReadyToFocus()resolves immediately and does not leave an unresolved entry inpromiseMap.melvin-bot commentedon Nov 12, 2026
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
robertjchen commentedon Nov 12, 2026
Thanks @parasharrajat. Let's keep this issue scoped and go with @wildan-m's proposal.
@neerajbachani the Concierge close case looks valid, but it's a separate focus path (
closeSidePaneland the focus trap). Changing those here adds regression risk to a fix that's otherwise small 🤔 Please report it in #expensify-bugs as its own issue and link it here 👍aion-citadel-forge commentedon Nov 12, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
On Web, after deleting a workspace (or closing any modal that unmounts while
isVisibleistrue), navigating to Spend > Reports, creating or opening a report, commenting on the empty report, right-clicking on the comment, and clicking Edit comment, the edit comment composer input does not receive focus.What is the root cause of that problem?
In
src/components/Modal/BaseModal.tsx:saveFocusStatecalls:src/libs/ComposerFocusManager.ts,resetReadyToFocuscreates an unresolved promise inpromiseMapkeyed to thatuniqueModalId.handleDismissModal()is invoked when!isVisible && wasVisibleinside theuseEffecton line 176:handleDismissModal()callsComposerFocusManager.setReadyToFocus(uniqueModalId), which resolves and deletes the entry inpromiseMap.isVisibleis stilltrue(such as confirming workspace deletion in Workspace Settings), the modal unmounts directly whileisVisibleremainstrue.!isVisible && wasVisibletransition never fires.BaseModal's unmount cleanup effect runs:hideModal()executesComposerFocusManager.refocusAfterModalFullyClosed(uniqueModalId, restoreFocusType), but it never callshandleDismissModal()orComposerFocusManager.setReadyToFocus(uniqueModalId).promiseMapretains an unresolved promise keyed to that unmounted modal indefinitely.focusComposerWithDelay(src/libs/focusComposerWithDelay/index.ts:59) executes:ComposerFocusManager.isReadyToFocus()awaits the dangling promise inpromiseMap, it blocks indefinitely and the composer input is never focused.What changes do you think we should make in order to solve the problem?
src/components/Modal/BaseModal.tsx:Ensure
handleDismissModal()is called during unmount cleanup whenshouldCallHideModalOnUnmount.currentistrue:src/libs/ComposerFocusManager.ts:In
restoreFocusState(id)or when cleaning up modals, callsetReadyToFocus(id)to resolve and remove any dangling promise associated with thatid:ComposerFocusManager.What alternative solutions did you explore? (Optional)
Adding arbitrary
setTimeoutdelays inReportActionComposeorfocusComposerWithDelay. This was rejected because it does not resolve the root lifecycle issue inBaseModal/ComposerFocusManagerand introduces timing flakes across platforms.Tests
aion-citadel-forge commentedon Nov 12, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
On Web, after deleting a workspace (or closing any modal that unmounts while
isVisibleistrue), navigating to Spend > Reports, creating or opening a report, commenting on the empty report, right-clicking on the comment, and clicking Edit comment, the edit comment composer input does not receive focus.What is the root cause of that problem?
In
src/components/Modal/BaseModal.tsx:saveFocusStatecalls:src/libs/ComposerFocusManager.ts,resetReadyToFocuscreates an unresolved promise inpromiseMapkeyed to thatuniqueModalId.handleDismissModal()is invoked when!isVisible && wasVisibleinside theuseEffecton line 176:handleDismissModal()callsComposerFocusManager.setReadyToFocus(uniqueModalId), which resolves and deletes the entry inpromiseMap.isVisibleis stilltrue(such as confirming workspace deletion in Workspace Settings), the modal unmounts directly whileisVisibleremainstrue.!isVisible && wasVisibletransition never fires.BaseModal's unmount cleanup effect runs:hideModal()executesComposerFocusManager.refocusAfterModalFullyClosed(uniqueModalId, restoreFocusType), but it never callshandleDismissModal()orComposerFocusManager.setReadyToFocus(uniqueModalId).promiseMapretains an unresolved promise keyed to that unmounted modal indefinitely.focusComposerWithDelay(src/libs/focusComposerWithDelay/index.ts:59) executes:ComposerFocusManager.isReadyToFocus()awaits the dangling promise inpromiseMap, it blocks indefinitely and the composer input is never focused.What changes do you think we should make in order to solve the problem?
src/components/Modal/BaseModal.tsx:Ensure
handleDismissModal()is called during unmount cleanup whenshouldCallHideModalOnUnmount.currentistrue:src/libs/ComposerFocusManager.ts:In
restoreFocusState(id)or when cleaning up modals, callsetReadyToFocus(id)to resolve and remove any dangling promise associated with thatid:ComposerFocusManager.What alternative solutions did you explore? (Optional)
Adding arbitrary
setTimeoutdelays inReportActionComposeorfocusComposerWithDelay. This was rejected because it does not resolve the root lifecycle issue inBaseModal/ComposerFocusManagerand introduces timing flakes across platforms.Tests
melvin-bot commentedon Nov 14, 2026
📣 @wildan-m 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!
Offer link
Upwork job
Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑💻
Keep in mind: Code of Conduct | Contributing 📖
parasharrajat commentedon Nov 14, 2026
Assigned Wildman based on this #104360 (comment)
wildan-m commentedon Nov 15, 2026
on it
wildan-m commentedon Nov 15, 2026
@parasharrajat the PR is ready for review: #106944