From 019954b2fc08a59b69be056ea51ac6f6674fb763 Mon Sep 17 00:00:00 2001 From: Alexey Kureev Date: Tue, 11 Nov 2025 12:23:24 +0100 Subject: [PATCH 01/46] fix: enforce composer layout reset upon sending a message --- .../ComposerWithSuggestions.tsx | 14 ++++++------- .../ReportActionCompose.tsx | 20 +++++++++++++------ 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx b/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx index f2b0794b3b1a..9693ae4b16ce 100644 --- a/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx +++ b/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx @@ -150,6 +150,7 @@ type ComposerRef = { * Once the composer ahs cleared onCleared will be called with the value that was cleared. */ clear: () => void; + reset: () => void; }; const {RNTextInputReset} = NativeModules; @@ -704,6 +705,9 @@ function ComposerWithSuggestions({ replaceSelectionWithText, isFocused: () => !!textInputRef.current?.isFocused(), clear, + reset: () => { + setComposerHeight(36); + }, getCurrentText, }), [blur, clear, focus, replaceSelectionWithText, getCurrentText], @@ -716,13 +720,9 @@ function ComposerWithSuggestions({ const onLayout = useCallback( (e: LayoutChangeEvent) => { onLayoutProps?.(e); - const composerLayoutHeight = e.nativeEvent.layout.height; - if (composerHeight === composerLayoutHeight) { - return; - } - setComposerHeight(composerLayoutHeight); + setComposerHeight(0); }, - [composerHeight, onLayoutProps], + [onLayoutProps], ); const onClear = useCallback( @@ -811,7 +811,7 @@ function ComposerWithSuggestions({ onChangeText={updateComment} onKeyPress={handleKeyPress} textAlignVertical="top" - style={[styles.textInputCompose, isComposerFullSize ? styles.textInputFullCompose : styles.textInputCollapseCompose]} + style={[styles.textInputCompose, isComposerFullSize ? styles.textInputFullCompose : styles.textInputCollapseCompose, composerHeight ? {height: composerHeight} : null]} maxLines={maxComposerLines} onFocus={handleFocus} onBlur={onBlur} diff --git a/src/pages/home/report/ReportActionCompose/ReportActionCompose.tsx b/src/pages/home/report/ReportActionCompose/ReportActionCompose.tsx index c1ed81759b79..c201f195c138 100644 --- a/src/pages/home/report/ReportActionCompose/ReportActionCompose.tsx +++ b/src/pages/home/report/ReportActionCompose/ReportActionCompose.tsx @@ -4,7 +4,8 @@ import React, {memo, useCallback, useEffect, useMemo, useRef, useState} from 're import type {BlurEvent, MeasureInWindowOnSuccessCallback, TextInputSelectionChangeEvent} from 'react-native'; import {View} from 'react-native'; import type {OnyxEntry} from 'react-native-onyx'; -import {runOnUI, useSharedValue} from 'react-native-reanimated'; +import {useSharedValue} from 'react-native-reanimated'; +import {scheduleOnUI} from 'react-native-worklets'; import type {Emoji} from '@assets/emojis/types'; import DragAndDropConsumer from '@components/DragAndDrop/Consumer'; import DropZoneUI from '@components/DropZone/DropZoneUI'; @@ -288,7 +289,7 @@ function ReportActionCompose({ throw new Error('The composerRef.clear function is not set yet. This should never happen, and indicates a developer error.'); } - runOnUI(clear)(); + scheduleOnUI(clear); }, []); /** @@ -397,14 +398,20 @@ function ReportActionCompose({ // useSharedValue on web doesn't support functions, so we need to wrap it in an object. const composerRefShared = useSharedValue<{ clear: (() => void) | undefined; - }>({clear: undefined}); + reset: (() => void) | undefined; + }>({clear: undefined, reset: undefined}); const handleSendMessage = useCallback(() => { if (isSendDisabled || !debouncedValidate.flush()) { return; } - runOnUI(() => { + const {reset} = composerRefShared.get(); + + reset?.(); + setIsComposerFullSize(reportID, false); + + scheduleOnUI(() => { 'worklet'; const {clear: clearComposer} = composerRefShared.get(); @@ -415,8 +422,8 @@ function ReportActionCompose({ // This will cause onCleared to be triggered where we actually send the message clearComposer?.(); - })(); - }, [isSendDisabled, debouncedValidate, composerRefShared]); + }); + }, [isSendDisabled, debouncedValidate, composerRefShared, reportID]); // eslint-disable-next-line react-compiler/react-compiler onSubmitAction = handleSendMessage; @@ -523,6 +530,7 @@ function ReportActionCompose({ composerRef.current = ref ?? undefined; composerRefShared.set({ clear: ref?.clear, + reset: ref?.reset, }); }} suggestionsRef={suggestionsRef} From b24156c427a5ebd29f9faf2f8de740902ec2681b Mon Sep 17 00:00:00 2001 From: Alexey Kureev Date: Tue, 9 Dec 2025 14:19:01 +0100 Subject: [PATCH 02/46] fix: remove magic constant --- .../ComposerWithSuggestions.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx b/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx index ca515c2dd27b..9cb182694784 100644 --- a/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx +++ b/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx @@ -268,6 +268,7 @@ function ComposerWithSuggestions({ const [selection, setSelection] = useState(() => ({start: value.length, end: value.length, positionX: 0, positionY: 0})); const [composerHeight, setComposerHeight] = useState(0); + const defaultComposerHeightRef = useRef(null); const textInputRef = useRef(null); @@ -724,7 +725,10 @@ function ComposerWithSuggestions({ isFocused: () => !!textInputRef.current?.isFocused(), clear, reset: () => { - setComposerHeight(36); + if (!defaultComposerHeightRef.current) { + return; + } + setComposerHeight(defaultComposerHeightRef.current); }, getCurrentText, }), @@ -799,6 +803,12 @@ function ComposerWithSuggestions({ const paddingTopAndBottom = (containerComposeStyles.paddingVertical as number) * 2; const inputHeight = e.nativeEvent.contentSize.height; const totalHeight = inputHeight + paddingTopAndBottom; + + if (defaultComposerHeightRef.current === null && inputHeight > 0 && !valueRef.current.includes('\n')) { + defaultComposerHeightRef.current = inputHeight; + setComposerHeight(inputHeight); + } + const isFullComposerAvailable = totalHeight >= CONST.COMPOSER.FULL_COMPOSER_MIN_HEIGHT; setIsFullComposerAvailable?.(isFullComposerAvailable); }, From b8bccacb5dd42f2c5938920703e690e6ec637962 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Tue, 3 Feb 2026 13:37:06 +0100 Subject: [PATCH 03/46] refactor: rename `reset` callback --- .../ComposerWithSuggestions.tsx | 4 ++-- .../report/ReportActionCompose/ReportActionCompose.tsx | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx b/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx index 1cbe75d0ea69..f2b923982289 100644 --- a/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx +++ b/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx @@ -162,7 +162,7 @@ type ComposerRef = { * Once the composer ahs cleared onCleared will be called with the value that was cleared. */ clear: () => void; - reset: () => void; + resetHeight: () => void; }; const {RNTextInputReset} = NativeModules; @@ -758,7 +758,7 @@ function ComposerWithSuggestions({ replaceSelectionWithText, isFocused: () => !!textInputRef.current?.isFocused(), clear, - reset: () => { + resetHeight: () => { if (!defaultComposerHeightRef.current) { return; } diff --git a/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx b/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx index 6ece64ca7f3f..ead9c9884e01 100644 --- a/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx +++ b/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx @@ -437,17 +437,17 @@ function ReportActionCompose({ // useSharedValue on web doesn't support functions, so we need to wrap it in an object. const composerRefShared = useSharedValue<{ clear: (() => void) | undefined; - reset: (() => void) | undefined; - }>({clear: undefined, reset: undefined}); + resetHeight: (() => void) | undefined; + }>({clear: undefined, resetHeight: undefined}); const handleSendMessage = useCallback(() => { if (isSendDisabled || !debouncedValidate.flush()) { return; } - const {reset} = composerRefShared.get(); + const {resetHeight} = composerRefShared.get(); - reset?.(); + resetHeight?.(); setIsComposerFullSize(reportID, false); scheduleOnUI(() => { @@ -576,7 +576,7 @@ function ReportActionCompose({ composerRef.current = ref ?? undefined; composerRefShared.set({ clear: ref?.clear as (() => void) | undefined, - reset: ref?.reset as (() => void) | undefined, + resetHeight: ref?.resetHeight as (() => void) | undefined, }); }} suggestionsRef={suggestionsRef} From b1383fc54798d618b208c594e7f9e160e3d1ab5d Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Tue, 3 Feb 2026 15:50:51 +0100 Subject: [PATCH 04/46] fix: unnecessary array wrapped style --- src/components/Composer/implementation/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Composer/implementation/index.tsx b/src/components/Composer/implementation/index.tsx index 7d181775ed4e..d8d01dd7c820 100755 --- a/src/components/Composer/implementation/index.tsx +++ b/src/components/Composer/implementation/index.tsx @@ -347,7 +347,7 @@ function Composer({ textInput.current = el; }} selection={selection} - style={[inputStyleMemo]} + style={inputStyleMemo} markdownStyle={markdownStyle} value={value} defaultValue={defaultValue} From 6f34303fec33429d3cb6cd2fc2f71fadaedc9819 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 4 Feb 2026 10:45:14 +0100 Subject: [PATCH 05/46] refactor: rename event property --- .../ComposerWithSuggestions/ComposerWithSuggestions.tsx | 8 ++++---- .../report/ReportActionCompose/ReportActionCompose.tsx | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx b/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx index f2b923982289..35591a52dc60 100644 --- a/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx +++ b/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx @@ -106,7 +106,7 @@ type ComposerWithSuggestionsProps = Partial & setIsCommentEmpty: (isCommentEmpty: boolean) => void; /** Function to handle sending a message */ - handleSendMessage: () => void; + onSendMessage: () => void; /** Whether the compose input should show */ shouldShowComposeInput: OnyxEntry; @@ -216,7 +216,7 @@ function ComposerWithSuggestions({ onPasteFile, disabled, setIsCommentEmpty, - handleSendMessage, + onSendMessage, shouldShowComposeInput, measureParentContainer = () => {}, isScrollLikelyLayoutTriggered, @@ -513,7 +513,7 @@ function ComposerWithSuggestions({ // Submit the form when Enter is pressed if (webEvent.key === CONST.KEYBOARD_SHORTCUTS.ENTER.shortcutKey && !webEvent.shiftKey) { webEvent.preventDefault(); - handleSendMessage(); + onSendMessage(); } // Trigger the edit box for last sent message if ArrowUp is pressed and the comment is empty and Chronos is not in the participants @@ -556,7 +556,7 @@ function ComposerWithSuggestions({ } } }, - [shouldUseNarrowLayout, isKeyboardShown, suggestionsRef, selection.start, includeChronos, handleSendMessage, lastReportAction, reportID, updateComment, selection.end], + [shouldUseNarrowLayout, isKeyboardShown, suggestionsRef, selection.start, includeChronos, onSendMessage, lastReportAction, reportID, updateComment, selection.end], ); const onChangeText = useCallback( diff --git a/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx b/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx index ead9c9884e01..d09656027970 100644 --- a/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx +++ b/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx @@ -596,7 +596,7 @@ function ReportActionCompose({ onCleared={submitForm} disabled={isBlockedFromConcierge || isEmojiPickerVisible()} setIsCommentEmpty={setIsCommentEmpty} - handleSendMessage={handleSendMessage} + onSendMessage={handleSendMessage} shouldShowComposeInput={shouldShowComposeInput} onFocus={onFocus} onBlur={onBlur} From ed3c905057488fea6f0800ce43934a09162150df Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 4 Feb 2026 11:20:12 +0100 Subject: [PATCH 06/46] fix: rename props --- .../ComposerWithSuggestions.tsx | 19 ++++++++----------- .../ReportActionCompose.tsx | 4 ++-- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx b/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx index 35591a52dc60..919d1f487916 100644 --- a/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx +++ b/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx @@ -82,7 +82,7 @@ type ComposerWithSuggestionsProps = Partial & onValueChange: (value: string) => void; /** Callback when the composer got cleared on the UI thread */ - onCleared?: (text: string) => void; + onClear?: (text: string) => void; /** Whether the composer is full size */ isComposerFullSize: boolean; @@ -106,7 +106,7 @@ type ComposerWithSuggestionsProps = Partial & setIsCommentEmpty: (isCommentEmpty: boolean) => void; /** Function to handle sending a message */ - onSendMessage: () => void; + onEnterKeyPress: () => void; /** Whether the compose input should show */ shouldShowComposeInput: OnyxEntry; @@ -216,12 +216,9 @@ function ComposerWithSuggestions({ onPasteFile, disabled, setIsCommentEmpty, - onSendMessage, - shouldShowComposeInput, - measureParentContainer = () => {}, + onEnterKeyPress, isScrollLikelyLayoutTriggered, - raiseIsScrollLikelyLayoutTriggered, - onCleared = () => {}, + onClear: onClearProp = () => {}, onLayout: onLayoutProps, // Refs @@ -513,7 +510,7 @@ function ComposerWithSuggestions({ // Submit the form when Enter is pressed if (webEvent.key === CONST.KEYBOARD_SHORTCUTS.ENTER.shortcutKey && !webEvent.shiftKey) { webEvent.preventDefault(); - onSendMessage(); + onEnterKeyPress(); } // Trigger the edit box for last sent message if ArrowUp is pressed and the comment is empty and Chronos is not in the participants @@ -556,7 +553,7 @@ function ComposerWithSuggestions({ } } }, - [shouldUseNarrowLayout, isKeyboardShown, suggestionsRef, selection.start, includeChronos, onSendMessage, lastReportAction, reportID, updateComment, selection.end], + [shouldUseNarrowLayout, isKeyboardShown, suggestionsRef, selection.start, includeChronos, onEnterKeyPress, lastReportAction, reportID, updateComment, selection.end], ); const onChangeText = useCallback( @@ -785,10 +782,10 @@ function ComposerWithSuggestions({ (text: string) => { mobileInputScrollPosition.current = 0; // Note: use the value when the clear happened, not the current value which might have changed already - onCleared(text); + onClearProp(text); updateComment('', true); }, - [onCleared, updateComment], + [onClearProp, updateComment], ); useEffect(() => { diff --git a/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx b/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx index d09656027970..37fb82553b44 100644 --- a/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx +++ b/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx @@ -593,10 +593,10 @@ function ReportActionCompose({ isComposerFullSize={isComposerFullSize} setIsFullComposerAvailable={setIsFullComposerAvailable} onPasteFile={(files) => validateAttachments({files})} - onCleared={submitForm} + onClear={submitForm} disabled={isBlockedFromConcierge || isEmojiPickerVisible()} setIsCommentEmpty={setIsCommentEmpty} - onSendMessage={handleSendMessage} + onEnterKeyPress={handleSendMessage} shouldShowComposeInput={shouldShowComposeInput} onFocus={onFocus} onBlur={onBlur} From f1a8be7088e027411ab5726b76ff65cc7475bafe Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 4 Feb 2026 11:33:21 +0100 Subject: [PATCH 07/46] fix: missing props --- .../ComposerWithSuggestions/ComposerWithSuggestions.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx b/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx index 919d1f487916..3a2cfb6453ba 100644 --- a/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx +++ b/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx @@ -217,7 +217,10 @@ function ComposerWithSuggestions({ disabled, setIsCommentEmpty, onEnterKeyPress, + shouldShowComposeInput, + measureParentContainer = () => {}, isScrollLikelyLayoutTriggered, + raiseIsScrollLikelyLayoutTriggered, onClear: onClearProp = () => {}, onLayout: onLayoutProps, @@ -885,7 +888,10 @@ function ComposerWithSuggestions({ onChangeText={onChangeText} onKeyPress={handleKeyPress} textAlignVertical="top" - style={[styles.textInputCompose, isComposerFullSize ? styles.textInputFullCompose : styles.textInputCollapseCompose, composerHeight ? {height: composerHeight} : null]} + style={[ + styles.textInputCompose, + isComposerFullSize ? styles.textInputFullCompose : styles.textInputCollapseCompose /* composerHeight ? {height: composerHeight} : null */, + ]} maxLines={maxComposerLines} onFocus={handleFocus} onBlur={onBlur} From 9643987d7cc9e2f58f3b48ac3682deb2aaf8005b Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 4 Feb 2026 11:33:37 +0100 Subject: [PATCH 08/46] fix: send message in new macrotask --- .../ReportActionCompose.tsx | 55 +++++++++++-------- 1 file changed, 33 insertions(+), 22 deletions(-) diff --git a/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx b/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx index 37fb82553b44..02d41cf193a6 100644 --- a/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx +++ b/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx @@ -334,28 +334,39 @@ function ReportActionCompose({ */ const submitForm = useCallback( (newComment: string) => { - const newCommentTrimmed = newComment.trim(); - - if (isConciergeChat) { - kickoffWaitingIndicator(); - } - - if (attachmentFileRef.current) { - addAttachmentWithComment(transactionThreadReport ?? report, reportID, ancestors, attachmentFileRef.current, newCommentTrimmed, personalDetail.timezone, true, isInSidePanel); - attachmentFileRef.current = null; - } else { - Performance.markStart(CONST.TIMING.SEND_MESSAGE, {message: newCommentTrimmed}); - Timing.start(CONST.TIMING.SEND_MESSAGE); - startSpan(CONST.TELEMETRY.SPAN_SEND_MESSAGE, { - name: 'send-message', - op: CONST.TELEMETRY.SPAN_SEND_MESSAGE, - attributes: { - [CONST.TELEMETRY.ATTRIBUTE_REPORT_ID]: reportID, - [CONST.TELEMETRY.ATTRIBUTE_MESSAGE_LENGTH]: newCommentTrimmed.length, - }, - }); - onSubmit(newCommentTrimmed); - } + setTimeout(() => { + const newCommentTrimmed = newComment.trim(); + + if (isConciergeChat) { + kickoffWaitingIndicator(); + } + + if (attachmentFileRef.current) { + addAttachmentWithComment( + transactionThreadReport ?? report, + reportID, + ancestors, + attachmentFileRef.current, + newCommentTrimmed, + personalDetail.timezone, + true, + isInSidePanel, + ); + attachmentFileRef.current = null; + } else { + Performance.markStart(CONST.TIMING.SEND_MESSAGE, {message: newCommentTrimmed}); + Timing.start(CONST.TIMING.SEND_MESSAGE); + startSpan(CONST.TELEMETRY.SPAN_SEND_MESSAGE, { + name: 'send-message', + op: CONST.TELEMETRY.SPAN_SEND_MESSAGE, + attributes: { + [CONST.TELEMETRY.ATTRIBUTE_REPORT_ID]: reportID, + [CONST.TELEMETRY.ATTRIBUTE_MESSAGE_LENGTH]: newCommentTrimmed.length, + }, + }); + onSubmit(newCommentTrimmed); + } + }, 0); }, [isConciergeChat, kickoffWaitingIndicator, transactionThreadReport, report, reportID, ancestors, personalDetail.timezone, onSubmit, isInSidePanel], ); From 02832f3fdb744ece7b7f1193bc89991adf7c370e Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 4 Feb 2026 11:51:03 +0100 Subject: [PATCH 09/46] fix: remove unnecessary "worklet" directive --- .../inbox/report/ReportActionCompose/ReportActionCompose.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx b/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx index 02d41cf193a6..9cc47aa2a241 100644 --- a/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx +++ b/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx @@ -462,8 +462,6 @@ function ReportActionCompose({ setIsComposerFullSize(reportID, false); scheduleOnUI(() => { - 'worklet'; - const {clear: clearComposer} = composerRefShared.get(); if (!clearComposer) { From c9fe00b80cdd4e5185274fbc0f56bc18ea837e2b Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 4 Feb 2026 11:51:30 +0100 Subject: [PATCH 10/46] refactor: update onLayout prop --- .../ComposerWithSuggestions.tsx | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx b/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx index 3a2cfb6453ba..6627244187b6 100644 --- a/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx +++ b/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx @@ -222,7 +222,7 @@ function ComposerWithSuggestions({ isScrollLikelyLayoutTriggered, raiseIsScrollLikelyLayoutTriggered, onClear: onClearProp = () => {}, - onLayout: onLayoutProps, + onLayout: onLayoutProp, // Refs suggestionsRef, @@ -773,14 +773,6 @@ function ComposerWithSuggestions({ onValueChange(value); }, [onValueChange, value]); - const onLayout = useCallback( - (e: LayoutChangeEvent) => { - onLayoutProps?.(e); - setComposerHeight(0); - }, - [onLayoutProps], - ); - const onClear = useCallback( (text: string) => { mobileInputScrollPosition.current = 0; @@ -909,7 +901,7 @@ function ComposerWithSuggestions({ value={value} testID="composer" shouldCalculateCaretPosition - onLayout={onLayout} + onLayout={onLayoutProp} onScroll={hideSuggestionMenu} shouldContainScroll={isMobileSafari()} isGroupPolicyReport={isGroupPolicyReport} From e8ef799f186a8313ae3a1bfadea9ced13098cd04 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 4 Feb 2026 11:56:56 +0100 Subject: [PATCH 11/46] rename props --- .../ComposerWithSuggestions/ComposerWithSuggestions.tsx | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx b/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx index 6627244187b6..02ae0ba39acd 100644 --- a/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx +++ b/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx @@ -824,7 +824,7 @@ function ComposerWithSuggestions({ const isTouchEndedRef = useRef(false); const containerComposeStyles = StyleSheet.flatten(StyleUtils.getContainerComposeStyles()); - const updateIsFullComposerAvailable = useCallback( + const handleContentSizeChange = useCallback( (e: TextInputContentSizeChangeEvent) => { const paddingTopAndBottom = (containerComposeStyles.paddingVertical as number) * 2; const inputHeight = e.nativeEvent.contentSize.height; @@ -880,10 +880,7 @@ function ComposerWithSuggestions({ onChangeText={onChangeText} onKeyPress={handleKeyPress} textAlignVertical="top" - style={[ - styles.textInputCompose, - isComposerFullSize ? styles.textInputFullCompose : styles.textInputCollapseCompose /* composerHeight ? {height: composerHeight} : null */, - ]} + style={[styles.textInputCompose, isComposerFullSize ? styles.textInputFullCompose : styles.textInputCollapseCompose, composerHeight ? {height: composerHeight} : null]} maxLines={maxComposerLines} onFocus={handleFocus} onBlur={onBlur} @@ -897,7 +894,7 @@ function ComposerWithSuggestions({ selection={selection} onSelectionChange={onSelectionChange} isComposerFullSize={isComposerFullSize} - onContentSizeChange={updateIsFullComposerAvailable} + onContentSizeChange={handleContentSizeChange} value={value} testID="composer" shouldCalculateCaretPosition From d184a52ce26940968865c8c281df795808f9176f Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 4 Feb 2026 12:24:23 +0100 Subject: [PATCH 12/46] chore: add comments --- .../ComposerWithSuggestions/ComposerWithSuggestions.tsx | 2 ++ .../inbox/report/ReportActionCompose/ReportActionCompose.tsx | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx b/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx index 02ae0ba39acd..cbbab78cb901 100644 --- a/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx +++ b/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx @@ -833,6 +833,8 @@ function ComposerWithSuggestions({ if (defaultComposerHeightRef.current === null && inputHeight > 0 && !valueRef.current.includes('\n')) { defaultComposerHeightRef.current = inputHeight; setComposerHeight(inputHeight); + // Once we cleared the input and the composer finished rendering, we need to reset the manual height value. + // After that, the composer will adjust it's height based on it's parent flex layout. } const isFullComposerAvailable = totalHeight >= CONST.COMPOSER.FULL_COMPOSER_MIN_HEIGHT; diff --git a/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx b/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx index 9cc47aa2a241..6072da44fcfb 100644 --- a/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx +++ b/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx @@ -334,6 +334,8 @@ function ReportActionCompose({ */ const submitForm = useCallback( (newComment: string) => { + // We need to use `setTimeout` toqueue the submission of the comment into a macro-task to ensure that + // the composer is cleared and it's height is updated before the JS thread is blocked by this logic. setTimeout(() => { const newCommentTrimmed = newComment.trim(); From fe716f5c485475bc5fee750cc6ca7b86687f532f Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 4 Feb 2026 12:24:52 +0100 Subject: [PATCH 13/46] refactor: rename clear worklet prop --- .../ComposerWithSuggestions.tsx | 8 ++++---- .../ReportActionCompose/ReportActionCompose.tsx | 14 +++++++------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx b/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx index cbbab78cb901..89245c5e58c8 100644 --- a/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx +++ b/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx @@ -161,7 +161,7 @@ type ComposerRef = { * Calling clear will immediately clear the input on the UI thread (its a worklet). * Once the composer ahs cleared onCleared will be called with the value that was cleared. */ - clear: () => void; + clearWorklet: () => void; resetHeight: () => void; }; @@ -678,7 +678,7 @@ function ComposerWithSuggestions({ textInputRef.current.blur(); }, []); - const clear = useCallback(() => { + const clearWorklet = useCallback(() => { 'worklet'; forceClearInput(animatedRef); @@ -757,16 +757,16 @@ function ComposerWithSuggestions({ focus, replaceSelectionWithText, isFocused: () => !!textInputRef.current?.isFocused(), - clear, resetHeight: () => { if (!defaultComposerHeightRef.current) { return; } setComposerHeight(defaultComposerHeightRef.current); }, + clearWorklet, getCurrentText, }), - [blur, clear, focus, replaceSelectionWithText, getCurrentText], + [blur, focus, replaceSelectionWithText, clearWorklet, resetHeight, getCurrentText], ); useEffect(() => { diff --git a/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx b/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx index 6072da44fcfb..9aada7df5f18 100644 --- a/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx +++ b/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx @@ -311,7 +311,7 @@ function ReportActionCompose({ const addAttachment = useCallback((file: FileObject | FileObject[]) => { attachmentFileRef.current = file; - const clear = composerRef.current?.clear; + const clear = composerRef.current?.clearWorklet; if (!clear) { throw new Error('The composerRef.clear function is not set yet. This should never happen, and indicates a developer error.'); } @@ -449,9 +449,9 @@ function ReportActionCompose({ // Note: using JS refs is not well supported in reanimated, thus we need to store the function in a shared value // useSharedValue on web doesn't support functions, so we need to wrap it in an object. const composerRefShared = useSharedValue<{ - clear: (() => void) | undefined; - resetHeight: (() => void) | undefined; - }>({clear: undefined, resetHeight: undefined}); + clearWorklet?: () => void; + resetHeight?: () => void; + }>({clearWorklet: undefined, resetHeight: undefined}); const handleSendMessage = useCallback(() => { if (isSendDisabled || !debouncedValidate.flush()) { @@ -464,7 +464,7 @@ function ReportActionCompose({ setIsComposerFullSize(reportID, false); scheduleOnUI(() => { - const {clear: clearComposer} = composerRefShared.get(); + const {clearWorklet: clearComposer} = composerRefShared.get(); if (!clearComposer) { throw new Error('The composerRefShared.clear function is not set yet. This should never happen, and indicates a developer error.'); @@ -586,8 +586,8 @@ function ReportActionCompose({ ref={(ref) => { composerRef.current = ref ?? undefined; composerRefShared.set({ - clear: ref?.clear as (() => void) | undefined, - resetHeight: ref?.resetHeight as (() => void) | undefined, + clearWorklet: ref?.clearWorklet, + resetHeight: ref?.resetHeight, }); }} suggestionsRef={suggestionsRef} From 6462feae1c91253c9b789613560e151fe264ac62 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 4 Feb 2026 12:24:59 +0100 Subject: [PATCH 14/46] fix: height reset on send --- .../ComposerWithSuggestions.tsx | 33 +++++++++++-------- src/styles/index.ts | 5 +++ 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx b/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx index 89245c5e58c8..01af4c91b4b9 100644 --- a/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx +++ b/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx @@ -283,8 +283,8 @@ function ComposerWithSuggestions({ const [selection, setSelection] = useState(() => ({start: value.length, end: value.length, positionX: 0, positionY: 0})); - const [composerHeight, setComposerHeight] = useState(0); - const defaultComposerHeightRef = useRef(null); + const [composerHeightAfterClear, setComposerHeightAfterClear] = useState(null); + const emptyComposerHeightRef = useRef(null); const textInputRef = useRef(null); @@ -684,6 +684,13 @@ function ComposerWithSuggestions({ forceClearInput(animatedRef); }, [animatedRef]); + const resetHeight = useCallback(() => { + if (!emptyComposerHeightRef.current) { + return; + } + setComposerHeightAfterClear(emptyComposerHeightRef.current); + }, []); + const getCurrentText = useCallback(() => { return commentRef.current; }, []); @@ -757,13 +764,8 @@ function ComposerWithSuggestions({ focus, replaceSelectionWithText, isFocused: () => !!textInputRef.current?.isFocused(), - resetHeight: () => { - if (!defaultComposerHeightRef.current) { - return; - } - setComposerHeight(defaultComposerHeightRef.current); - }, clearWorklet, + resetHeight, getCurrentText, }), [blur, focus, replaceSelectionWithText, clearWorklet, resetHeight, getCurrentText], @@ -830,11 +832,12 @@ function ComposerWithSuggestions({ const inputHeight = e.nativeEvent.contentSize.height; const totalHeight = inputHeight + paddingTopAndBottom; - if (defaultComposerHeightRef.current === null && inputHeight > 0 && !valueRef.current.includes('\n')) { - defaultComposerHeightRef.current = inputHeight; - setComposerHeight(inputHeight); // Once we cleared the input and the composer finished rendering, we need to reset the manual height value. // After that, the composer will adjust it's height based on it's parent flex layout. + setComposerHeightAfterClear(null); + + if (emptyComposerHeightRef.current === null && totalHeight > 0 && !valueRef.current.includes('\n')) { + emptyComposerHeightRef.current = totalHeight; } const isFullComposerAvailable = totalHeight >= CONST.COMPOSER.FULL_COMPOSER_MIN_HEIGHT; @@ -867,7 +870,7 @@ function ComposerWithSuggestions({ return ( <> { isTouchEndedRef.current = true; }} @@ -882,7 +885,11 @@ function ComposerWithSuggestions({ onChangeText={onChangeText} onKeyPress={handleKeyPress} textAlignVertical="top" - style={[styles.textInputCompose, isComposerFullSize ? styles.textInputFullCompose : styles.textInputCollapseCompose, composerHeight ? {height: composerHeight} : null]} + style={[ + styles.textInputCompose, + isComposerFullSize ? styles.textInputFullCompose : styles.textInputCollapseCompose, + composerHeightAfterClear != null && {height: composerHeightAfterClear}, + ]} maxLines={maxComposerLines} onFocus={handleFocus} onBlur={onBlur} diff --git a/src/styles/index.ts b/src/styles/index.ts index 2c3948ac93ab..5901b97738b1 100644 --- a/src/styles/index.ts +++ b/src/styles/index.ts @@ -2155,6 +2155,11 @@ const staticStyles = (theme: ThemeColors) => flex: 4, }, + textInputComposeAfterClear: { + flexDirection: 'column', + alignItems: 'center', + }, + // composer padding should not be modified unless thoroughly tested against the cases in this PR: #12669 textInputComposeSpacing: { paddingVertical: 5, From 6734dcb8c951e73a54d72f8fea110391efaeac5d Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 4 Feb 2026 12:27:14 +0100 Subject: [PATCH 15/46] fix: spell check --- .../inbox/report/ReportActionCompose/ReportActionCompose.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx b/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx index 9aada7df5f18..881c9c0cda2b 100644 --- a/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx +++ b/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx @@ -334,7 +334,7 @@ function ReportActionCompose({ */ const submitForm = useCallback( (newComment: string) => { - // We need to use `setTimeout` toqueue the submission of the comment into a macro-task to ensure that + // We need to use `setTimeout` to queue the submission of the comment into a macro-task to ensure that // the composer is cleared and it's height is updated before the JS thread is blocked by this logic. setTimeout(() => { const newCommentTrimmed = newComment.trim(); From cab19fa02d2f9b64afae9462bff85dc9aee6f60a Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 4 Feb 2026 12:31:54 +0100 Subject: [PATCH 16/46] refactor: remove property alias --- .../ComposerWithSuggestions/ComposerWithSuggestions.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx b/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx index 01af4c91b4b9..ead0476b8fbc 100644 --- a/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx +++ b/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx @@ -222,7 +222,7 @@ function ComposerWithSuggestions({ isScrollLikelyLayoutTriggered, raiseIsScrollLikelyLayoutTriggered, onClear: onClearProp = () => {}, - onLayout: onLayoutProp, + onLayout, // Refs suggestionsRef, @@ -907,7 +907,7 @@ function ComposerWithSuggestions({ value={value} testID="composer" shouldCalculateCaretPosition - onLayout={onLayoutProp} + onLayout={onLayout} onScroll={hideSuggestionMenu} shouldContainScroll={isMobileSafari()} isGroupPolicyReport={isGroupPolicyReport} From 38d7731ad0bfde1abc4d7cb17ee40ead924926ce Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 4 Feb 2026 14:36:07 +0100 Subject: [PATCH 17/46] fix: failing test --- Mobile-Expensify | 2 +- tests/ui/ReportActionComposeTest.tsx | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Mobile-Expensify b/Mobile-Expensify index a92777fbadfc..013f26c1e94d 160000 --- a/Mobile-Expensify +++ b/Mobile-Expensify @@ -1 +1 @@ -Subproject commit a92777fbadfc660e19508d03464e4355324ce4d4 +Subproject commit 013f26c1e94df6e040e45ea28c0d2113c7d2fcd5 diff --git a/tests/ui/ReportActionComposeTest.tsx b/tests/ui/ReportActionComposeTest.tsx index a9eecd42f649..6034c6208fe8 100644 --- a/tests/ui/ReportActionComposeTest.tsx +++ b/tests/ui/ReportActionComposeTest.tsx @@ -252,6 +252,8 @@ describe('ReportActionCompose Integration Tests', () => { jest.advanceTimersByTime(1); }); + await waitForBatchedUpdatesWithAct(); + // Then the message should be sent expect(mockForceClearInput).toHaveBeenCalledTimes(1); }); @@ -267,6 +269,8 @@ describe('ReportActionCompose Integration Tests', () => { // When the message is submitted act(onSubmitAction); + await waitForBatchedUpdatesWithAct(); + // Then the message should NOT be sent expect(mockForceClearInput).toHaveBeenCalledTimes(0); From 6369b4a2394a4f4c5dee90f3a8006bb1e16d24da Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 4 Feb 2026 15:12:34 +0100 Subject: [PATCH 18/46] revert: Mobile-Expensify change --- Mobile-Expensify | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mobile-Expensify b/Mobile-Expensify index 013f26c1e94d..a92777fbadfc 160000 --- a/Mobile-Expensify +++ b/Mobile-Expensify @@ -1 +1 @@ -Subproject commit 013f26c1e94df6e040e45ea28c0d2113c7d2fcd5 +Subproject commit a92777fbadfc660e19508d03464e4355324ce4d4 From 55027e233e774182a35e4ee441bd7f6f8597198b Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 4 Feb 2026 15:29:48 +0100 Subject: [PATCH 19/46] fix: failing tests --- tests/ui/ReportActionComposeTest.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/ui/ReportActionComposeTest.tsx b/tests/ui/ReportActionComposeTest.tsx index 6034c6208fe8..186bbf6c80e2 100644 --- a/tests/ui/ReportActionComposeTest.tsx +++ b/tests/ui/ReportActionComposeTest.tsx @@ -249,11 +249,9 @@ describe('ReportActionCompose Integration Tests', () => { // scheduleOnUI mock uses setTimeout(() => ..., 0) act(() => { - jest.advanceTimersByTime(1); + jest.advanceTimersByTime(2); }); - await waitForBatchedUpdatesWithAct(); - // Then the message should be sent expect(mockForceClearInput).toHaveBeenCalledTimes(1); }); @@ -269,7 +267,9 @@ describe('ReportActionCompose Integration Tests', () => { // When the message is submitted act(onSubmitAction); - await waitForBatchedUpdatesWithAct(); + act(() => { + jest.advanceTimersByTime(1); + }); // Then the message should NOT be sent expect(mockForceClearInput).toHaveBeenCalledTimes(0); From 4855c2c6504b7b47b3498c1cfa5b1451e4e3b062 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Thu, 5 Feb 2026 12:05:05 +0100 Subject: [PATCH 20/46] fix: vertical/horizontal alignment of composer --- src/styles/index.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/styles/index.ts b/src/styles/index.ts index 5901b97738b1..99ae84862503 100644 --- a/src/styles/index.ts +++ b/src/styles/index.ts @@ -2156,8 +2156,7 @@ const staticStyles = (theme: ThemeColors) => }, textInputComposeAfterClear: { - flexDirection: 'column', - alignItems: 'center', + justifyContent: 'center', }, // composer padding should not be modified unless thoroughly tested against the cases in this PR: #12669 From c4abcda1b971c00c966679c64098fcd29543d371 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Thu, 5 Feb 2026 12:10:08 +0100 Subject: [PATCH 21/46] fix: clear composer when text is inputted --- .../ComposerWithSuggestions.tsx | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx b/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx index ead0476b8fbc..1c6c34bb4081 100644 --- a/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx +++ b/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx @@ -559,8 +559,21 @@ function ComposerWithSuggestions({ [shouldUseNarrowLayout, isKeyboardShown, suggestionsRef, selection.start, includeChronos, onEnterKeyPress, lastReportAction, reportID, updateComment, selection.end], ); + /** + * Once we cleared the input and the composer finished rendering, we need to reset the manual height value. + * After that, the composer will adjust it's height based on it's parent flex layout. + */ + const clearComposerHeightAfterClear = useCallback(() => { + if (composerHeightAfterClear == null) { + return; + } + setComposerHeightAfterClear(null); + }, [composerHeightAfterClear]); + const onChangeText = useCallback( (commentValue: string) => { + clearComposerHeightAfterClear(); + updateComment(commentValue, true); if (isIOSNative && syncSelectionWithOnChangeTextRef.current) { @@ -576,7 +589,7 @@ function ComposerWithSuggestions({ }); } }, - [updateComment], + [clearComposerHeightAfterClear, updateComment], ); const onSelectionChange = useCallback( @@ -832,9 +845,7 @@ function ComposerWithSuggestions({ const inputHeight = e.nativeEvent.contentSize.height; const totalHeight = inputHeight + paddingTopAndBottom; - // Once we cleared the input and the composer finished rendering, we need to reset the manual height value. - // After that, the composer will adjust it's height based on it's parent flex layout. - setComposerHeightAfterClear(null); + clearComposerHeightAfterClear(); if (emptyComposerHeightRef.current === null && totalHeight > 0 && !valueRef.current.includes('\n')) { emptyComposerHeightRef.current = totalHeight; @@ -843,7 +854,7 @@ function ComposerWithSuggestions({ const isFullComposerAvailable = totalHeight >= CONST.COMPOSER.FULL_COMPOSER_MIN_HEIGHT; setIsFullComposerAvailable?.(isFullComposerAvailable); }, - [setIsFullComposerAvailable, containerComposeStyles], + [containerComposeStyles.paddingVertical, clearComposerHeightAfterClear, setIsFullComposerAvailable], ); const handleFocus = useCallback(() => { From cb7f1518e2c029944f166e5fd02718f100b54034 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Thu, 5 Feb 2026 12:55:39 +0100 Subject: [PATCH 22/46] fix: failing test due to added `setTimeout` --- tests/ui/ReportActionComposeTest.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/ui/ReportActionComposeTest.tsx b/tests/ui/ReportActionComposeTest.tsx index 186bbf6c80e2..1cc2ca559a23 100644 --- a/tests/ui/ReportActionComposeTest.tsx +++ b/tests/ui/ReportActionComposeTest.tsx @@ -247,11 +247,12 @@ describe('ReportActionCompose Integration Tests', () => { // When the message is submitted act(onSubmitAction); - // scheduleOnUI mock uses setTimeout(() => ..., 0) act(() => { - jest.advanceTimersByTime(2); + jest.runAllTimers(); }); + await waitForBatchedUpdatesWithAct(); + // Then the message should be sent expect(mockForceClearInput).toHaveBeenCalledTimes(1); }); @@ -268,9 +269,11 @@ describe('ReportActionCompose Integration Tests', () => { act(onSubmitAction); act(() => { - jest.advanceTimersByTime(1); + jest.runAllTimers(); }); + await waitForBatchedUpdatesWithAct(); + // Then the message should NOT be sent expect(mockForceClearInput).toHaveBeenCalledTimes(0); From 827ddc5e6089c8979b53695564b597feb36c20d1 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Fri, 6 Feb 2026 11:21:58 +0100 Subject: [PATCH 23/46] fix: tests --- tests/ui/ReportActionComposeTest.tsx | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/tests/ui/ReportActionComposeTest.tsx b/tests/ui/ReportActionComposeTest.tsx index 1cc2ca559a23..bc99a83f0390 100644 --- a/tests/ui/ReportActionComposeTest.tsx +++ b/tests/ui/ReportActionComposeTest.tsx @@ -247,12 +247,11 @@ describe('ReportActionCompose Integration Tests', () => { // When the message is submitted act(onSubmitAction); + // Advance timers to allow the setTimeout in scheduleOnUI mock to run act(() => { - jest.runAllTimers(); + jest.advanceTimersByTime(1); }); - await waitForBatchedUpdatesWithAct(); - // Then the message should be sent expect(mockForceClearInput).toHaveBeenCalledTimes(1); }); @@ -265,15 +264,14 @@ describe('ReportActionCompose Integration Tests', () => { const invalidMessage = 'x'.repeat(CONST.MAX_COMMENT_LENGTH + 1); fireEvent.changeText(composer, invalidMessage); - // When the message is submitted + // When the message is submitted (validation should fail, so no setTimeout is scheduled) act(onSubmitAction); + // Advance timers to ensure any pending async work completes act(() => { - jest.runAllTimers(); + jest.advanceTimersByTime(CONST.TIMING.COMMENT_LENGTH_DEBOUNCE_TIME + 1); }); - await waitForBatchedUpdatesWithAct(); - // Then the message should NOT be sent expect(mockForceClearInput).toHaveBeenCalledTimes(0); From 4e3daec06e670f1baf4c41df913d3633fd66f2ba Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Fri, 6 Feb 2026 11:48:37 +0100 Subject: [PATCH 24/46] chroe: add comments --- .../ComposerWithSuggestions/ComposerWithSuggestions.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx b/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx index 1c6c34bb4081..e02221435aca 100644 --- a/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx +++ b/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx @@ -572,6 +572,8 @@ function ComposerWithSuggestions({ const onChangeText = useCallback( (commentValue: string) => { + // When we clear the input, we set the composer height to a specific value. + // Upon text change, we can reset the height to allow flex layout to adjust the height. clearComposerHeightAfterClear(); updateComment(commentValue, true); @@ -845,8 +847,11 @@ function ComposerWithSuggestions({ const inputHeight = e.nativeEvent.contentSize.height; const totalHeight = inputHeight + paddingTopAndBottom; + // When we clear the input, we set the composer height to a specific value. + // Upon any content size change, we can reset the height to allow flex layout to adjust the height. clearComposerHeightAfterClear(); + // Store the default collapsed composer height, so we can later reset the height when we clear the input. if (emptyComposerHeightRef.current === null && totalHeight > 0 && !valueRef.current.includes('\n')) { emptyComposerHeightRef.current = totalHeight; } From ae9b154813ed2ef29836263747db37375239b29f Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Fri, 6 Feb 2026 13:17:07 +0100 Subject: [PATCH 25/46] fix: alignment on all platforms --- .../ComposerWithSuggestions/ComposerWithSuggestions.tsx | 4 ++-- src/styles/index.ts | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx b/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx index e02221435aca..86bf01bf608d 100644 --- a/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx +++ b/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx @@ -852,8 +852,8 @@ function ComposerWithSuggestions({ clearComposerHeightAfterClear(); // Store the default collapsed composer height, so we can later reset the height when we clear the input. - if (emptyComposerHeightRef.current === null && totalHeight > 0 && !valueRef.current.includes('\n')) { - emptyComposerHeightRef.current = totalHeight; + if (emptyComposerHeightRef.current === null && inputHeight > 0 && !valueRef.current.includes('\n')) { + emptyComposerHeightRef.current = inputHeight; } const isFullComposerAvailable = totalHeight >= CONST.COMPOSER.FULL_COMPOSER_MIN_HEIGHT; diff --git a/src/styles/index.ts b/src/styles/index.ts index 540e28e42e40..e0e730da4e07 100644 --- a/src/styles/index.ts +++ b/src/styles/index.ts @@ -2135,7 +2135,6 @@ const staticStyles = (theme: ThemeColors) => ...(Platform.OS === 'android' && { height: undefined, lineHeight: undefined, - alignSelf: 'stretch', flexGrow: 1, flexShrink: 1, }), From fb2ac0e615af84fa0c817b9976f34640c1c25a11 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Fri, 6 Feb 2026 13:26:24 +0100 Subject: [PATCH 26/46] fix: remove manual `setTimeout` --- .../ReportActionCompose.tsx | 57 +++++++------------ 1 file changed, 22 insertions(+), 35 deletions(-) diff --git a/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx b/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx index 881c9c0cda2b..fe66944d61ca 100644 --- a/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx +++ b/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx @@ -334,41 +334,28 @@ function ReportActionCompose({ */ const submitForm = useCallback( (newComment: string) => { - // We need to use `setTimeout` to queue the submission of the comment into a macro-task to ensure that - // the composer is cleared and it's height is updated before the JS thread is blocked by this logic. - setTimeout(() => { - const newCommentTrimmed = newComment.trim(); - - if (isConciergeChat) { - kickoffWaitingIndicator(); - } - - if (attachmentFileRef.current) { - addAttachmentWithComment( - transactionThreadReport ?? report, - reportID, - ancestors, - attachmentFileRef.current, - newCommentTrimmed, - personalDetail.timezone, - true, - isInSidePanel, - ); - attachmentFileRef.current = null; - } else { - Performance.markStart(CONST.TIMING.SEND_MESSAGE, {message: newCommentTrimmed}); - Timing.start(CONST.TIMING.SEND_MESSAGE); - startSpan(CONST.TELEMETRY.SPAN_SEND_MESSAGE, { - name: 'send-message', - op: CONST.TELEMETRY.SPAN_SEND_MESSAGE, - attributes: { - [CONST.TELEMETRY.ATTRIBUTE_REPORT_ID]: reportID, - [CONST.TELEMETRY.ATTRIBUTE_MESSAGE_LENGTH]: newCommentTrimmed.length, - }, - }); - onSubmit(newCommentTrimmed); - } - }, 0); + const newCommentTrimmed = newComment.trim(); + + if (isConciergeChat) { + kickoffWaitingIndicator(); + } + + if (attachmentFileRef.current) { + addAttachmentWithComment(transactionThreadReport ?? report, reportID, ancestors, attachmentFileRef.current, newCommentTrimmed, personalDetail.timezone, true, isInSidePanel); + attachmentFileRef.current = null; + } else { + Performance.markStart(CONST.TIMING.SEND_MESSAGE, {message: newCommentTrimmed}); + Timing.start(CONST.TIMING.SEND_MESSAGE); + startSpan(CONST.TELEMETRY.SPAN_SEND_MESSAGE, { + name: 'send-message', + op: CONST.TELEMETRY.SPAN_SEND_MESSAGE, + attributes: { + [CONST.TELEMETRY.ATTRIBUTE_REPORT_ID]: reportID, + [CONST.TELEMETRY.ATTRIBUTE_MESSAGE_LENGTH]: newCommentTrimmed.length, + }, + }); + onSubmit(newCommentTrimmed); + } }, [isConciergeChat, kickoffWaitingIndicator, transactionThreadReport, report, reportID, ancestors, personalDetail.timezone, onSubmit, isInSidePanel], ); From 3fc77ccbf35ac8f979f9fcfb7ec6314edcd2ecf4 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Fri, 6 Feb 2026 14:24:48 +0100 Subject: [PATCH 27/46] revert: unrelated change --- src/components/Composer/implementation/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Composer/implementation/index.tsx b/src/components/Composer/implementation/index.tsx index d8d01dd7c820..7d181775ed4e 100755 --- a/src/components/Composer/implementation/index.tsx +++ b/src/components/Composer/implementation/index.tsx @@ -347,7 +347,7 @@ function Composer({ textInput.current = el; }} selection={selection} - style={inputStyleMemo} + style={[inputStyleMemo]} markdownStyle={markdownStyle} value={value} defaultValue={defaultValue} From f15fdff844a699f5c7304bdb4a7c1c4890902371 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Fri, 6 Feb 2026 14:28:44 +0100 Subject: [PATCH 28/46] revert test changes --- tests/ui/ReportActionComposeTest.tsx | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/tests/ui/ReportActionComposeTest.tsx b/tests/ui/ReportActionComposeTest.tsx index bc99a83f0390..a9eecd42f649 100644 --- a/tests/ui/ReportActionComposeTest.tsx +++ b/tests/ui/ReportActionComposeTest.tsx @@ -247,7 +247,7 @@ describe('ReportActionCompose Integration Tests', () => { // When the message is submitted act(onSubmitAction); - // Advance timers to allow the setTimeout in scheduleOnUI mock to run + // scheduleOnUI mock uses setTimeout(() => ..., 0) act(() => { jest.advanceTimersByTime(1); }); @@ -264,14 +264,9 @@ describe('ReportActionCompose Integration Tests', () => { const invalidMessage = 'x'.repeat(CONST.MAX_COMMENT_LENGTH + 1); fireEvent.changeText(composer, invalidMessage); - // When the message is submitted (validation should fail, so no setTimeout is scheduled) + // When the message is submitted act(onSubmitAction); - // Advance timers to ensure any pending async work completes - act(() => { - jest.advanceTimersByTime(CONST.TIMING.COMMENT_LENGTH_DEBOUNCE_TIME + 1); - }); - // Then the message should NOT be sent expect(mockForceClearInput).toHaveBeenCalledTimes(0); From d2c83db72cc9770f5aefa8d8dd9ec1499a0bb473 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Fri, 6 Feb 2026 14:29:13 +0100 Subject: [PATCH 29/46] docs: add missing JSDoc --- .../ComposerWithSuggestions/ComposerWithSuggestions.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx b/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx index 86bf01bf608d..af9eb9456a83 100644 --- a/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx +++ b/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx @@ -157,11 +157,16 @@ type ComposerRef = { replaceSelectionWithText: OnEmojiSelected; getCurrentText: () => string; isFocused: () => boolean; + /** * Calling clear will immediately clear the input on the UI thread (its a worklet). * Once the composer ahs cleared onCleared will be called with the value that was cleared. */ clearWorklet: () => void; + + /** + * Reset the height of the composer. + */ resetHeight: () => void; }; From cd032b208a1c552d37e357906cd65e5cacd44f01 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Fri, 6 Feb 2026 14:37:23 +0100 Subject: [PATCH 30/46] refactor: variables and callbacks in `ComposerWithSuggestions` --- .../ComposerWithSuggestions.tsx | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx b/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx index af9eb9456a83..7888daa585d0 100644 --- a/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx +++ b/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx @@ -288,7 +288,7 @@ function ComposerWithSuggestions({ const [selection, setSelection] = useState(() => ({start: value.length, end: value.length, positionX: 0, positionY: 0})); - const [composerHeightAfterClear, setComposerHeightAfterClear] = useState(null); + const [defaultComposerHeight, setDefaultComposerHeight] = useState(null); const emptyComposerHeightRef = useRef(null); const textInputRef = useRef(null); @@ -568,18 +568,18 @@ function ComposerWithSuggestions({ * Once we cleared the input and the composer finished rendering, we need to reset the manual height value. * After that, the composer will adjust it's height based on it's parent flex layout. */ - const clearComposerHeightAfterClear = useCallback(() => { - if (composerHeightAfterClear == null) { + const clearComposerHeight = useCallback(() => { + if (defaultComposerHeight == null) { return; } - setComposerHeightAfterClear(null); - }, [composerHeightAfterClear]); + setDefaultComposerHeight(null); + }, [defaultComposerHeight]); const onChangeText = useCallback( (commentValue: string) => { // When we clear the input, we set the composer height to a specific value. // Upon text change, we can reset the height to allow flex layout to adjust the height. - clearComposerHeightAfterClear(); + clearComposerHeight(); updateComment(commentValue, true); @@ -596,7 +596,7 @@ function ComposerWithSuggestions({ }); } }, - [clearComposerHeightAfterClear, updateComment], + [clearComposerHeight, updateComment], ); const onSelectionChange = useCallback( @@ -708,7 +708,7 @@ function ComposerWithSuggestions({ if (!emptyComposerHeightRef.current) { return; } - setComposerHeightAfterClear(emptyComposerHeightRef.current); + setDefaultComposerHeight(emptyComposerHeightRef.current); }, []); const getCurrentText = useCallback(() => { @@ -854,7 +854,7 @@ function ComposerWithSuggestions({ // When we clear the input, we set the composer height to a specific value. // Upon any content size change, we can reset the height to allow flex layout to adjust the height. - clearComposerHeightAfterClear(); + clearComposerHeight(); // Store the default collapsed composer height, so we can later reset the height when we clear the input. if (emptyComposerHeightRef.current === null && inputHeight > 0 && !valueRef.current.includes('\n')) { @@ -864,7 +864,7 @@ function ComposerWithSuggestions({ const isFullComposerAvailable = totalHeight >= CONST.COMPOSER.FULL_COMPOSER_MIN_HEIGHT; setIsFullComposerAvailable?.(isFullComposerAvailable); }, - [containerComposeStyles.paddingVertical, clearComposerHeightAfterClear, setIsFullComposerAvailable], + [containerComposeStyles.paddingVertical, clearComposerHeight, setIsFullComposerAvailable], ); const handleFocus = useCallback(() => { @@ -891,7 +891,7 @@ function ComposerWithSuggestions({ return ( <> { isTouchEndedRef.current = true; }} @@ -909,7 +909,7 @@ function ComposerWithSuggestions({ style={[ styles.textInputCompose, isComposerFullSize ? styles.textInputFullCompose : styles.textInputCollapseCompose, - composerHeightAfterClear != null && {height: composerHeightAfterClear}, + defaultComposerHeight != null && {height: defaultComposerHeight}, ]} maxLines={maxComposerLines} onFocus={handleFocus} From be44f8925b692a70ff74d55f6c32f973e0cf6e28 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Fri, 6 Feb 2026 14:37:39 +0100 Subject: [PATCH 31/46] refactor: simplify (shared) ref to composer --- .../report/ReportActionCompose/ReportActionCompose.tsx | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx b/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx index fe66944d61ca..9a9bc10d31cb 100644 --- a/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx +++ b/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx @@ -435,19 +435,14 @@ function ReportActionCompose({ // Note: using JS refs is not well supported in reanimated, thus we need to store the function in a shared value // useSharedValue on web doesn't support functions, so we need to wrap it in an object. - const composerRefShared = useSharedValue<{ - clearWorklet?: () => void; - resetHeight?: () => void; - }>({clearWorklet: undefined, resetHeight: undefined}); + const composerRefShared = useSharedValue>({}); const handleSendMessage = useCallback(() => { if (isSendDisabled || !debouncedValidate.flush()) { return; } - const {resetHeight} = composerRefShared.get(); - - resetHeight?.(); + composerRef.current?.resetHeight(); setIsComposerFullSize(reportID, false); scheduleOnUI(() => { @@ -574,7 +569,6 @@ function ReportActionCompose({ composerRef.current = ref ?? undefined; composerRefShared.set({ clearWorklet: ref?.clearWorklet, - resetHeight: ref?.resetHeight, }); }} suggestionsRef={suggestionsRef} From b69fc29e467d8b6cfabc1c231008304495c5e75d Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Fri, 6 Feb 2026 14:37:49 +0100 Subject: [PATCH 32/46] test: add act to wait for `setTimeout` --- tests/ui/ReportActionComposeTest.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/ui/ReportActionComposeTest.tsx b/tests/ui/ReportActionComposeTest.tsx index a9eecd42f649..9762bdb46a83 100644 --- a/tests/ui/ReportActionComposeTest.tsx +++ b/tests/ui/ReportActionComposeTest.tsx @@ -267,6 +267,11 @@ describe('ReportActionCompose Integration Tests', () => { // When the message is submitted act(onSubmitAction); + // scheduleOnUI mock uses setTimeout(() => ..., 0) + act(() => { + jest.advanceTimersByTime(1); + }); + // Then the message should NOT be sent expect(mockForceClearInput).toHaveBeenCalledTimes(0); From 07cc25dbd4092f6156d7c546f375c66e2add5a33 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Fri, 6 Feb 2026 15:43:02 +0100 Subject: [PATCH 33/46] fix: tests --- tests/ui/ReportActionComposeTest.tsx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tests/ui/ReportActionComposeTest.tsx b/tests/ui/ReportActionComposeTest.tsx index 9762bdb46a83..27955c8b28e5 100644 --- a/tests/ui/ReportActionComposeTest.tsx +++ b/tests/ui/ReportActionComposeTest.tsx @@ -237,7 +237,7 @@ describe('ReportActionCompose Integration Tests', () => { }); it('should send when length is within the limit', async () => { - renderReportActionCompose(); + const {unmount} = renderReportActionCompose(); const composer = screen.getByTestId('composer'); // Given a message that is within the length limit @@ -254,10 +254,13 @@ describe('ReportActionCompose Integration Tests', () => { // Then the message should be sent expect(mockForceClearInput).toHaveBeenCalledTimes(1); + + unmount(); + await waitForBatchedUpdatesWithAct(); }); it('should not send when length exceeds the limit', async () => { - renderReportActionCompose(); + const {unmount} = renderReportActionCompose(); const composer = screen.getByTestId('composer'); // Given a message that is over the length limit @@ -267,16 +270,14 @@ describe('ReportActionCompose Integration Tests', () => { // When the message is submitted act(onSubmitAction); - // scheduleOnUI mock uses setTimeout(() => ..., 0) - act(() => { - jest.advanceTimersByTime(1); - }); - // Then the message should NOT be sent expect(mockForceClearInput).toHaveBeenCalledTimes(0); // And the error should be displayed expect(screen.getByText('composer.commentExceededMaxLength')).toBeOnTheScreen(); + + unmount(); + await waitForBatchedUpdatesWithAct(); }); }); }); From 6085a1d46e520c3944bea6ea4df658084977637a Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Tue, 10 Feb 2026 18:58:25 +0000 Subject: [PATCH 34/46] fix: failing tests --- .../inbox/report/ReportActionCompose/ReportActionCompose.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx b/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx index a1d35b8522e4..d54ceee962c3 100644 --- a/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx +++ b/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx @@ -453,9 +453,9 @@ function ReportActionCompose({ composerRef.current?.resetHeight(); setIsComposerFullSize(reportID, false); - scheduleOnUI(() => { - const {clearWorklet: clearComposer} = composerRefShared.get(); + const {clearWorklet: clearComposer} = composerRefShared.get(); + scheduleOnUI(() => { if (!clearComposer) { throw new Error('The composerRefShared.clear function is not set yet. This should never happen, and indicates a developer error.'); } From 5a9e88e6632441a8eb9d621bf85185705689c31f Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Tue, 10 Feb 2026 20:09:35 +0000 Subject: [PATCH 35/46] refactor: move back shared ref usage --- .../inbox/report/ReportActionCompose/ReportActionCompose.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx b/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx index d54ceee962c3..a1d35b8522e4 100644 --- a/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx +++ b/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx @@ -453,9 +453,9 @@ function ReportActionCompose({ composerRef.current?.resetHeight(); setIsComposerFullSize(reportID, false); - const {clearWorklet: clearComposer} = composerRefShared.get(); - scheduleOnUI(() => { + const {clearWorklet: clearComposer} = composerRefShared.get(); + if (!clearComposer) { throw new Error('The composerRefShared.clear function is not set yet. This should never happen, and indicates a developer error.'); } From 71d1a0284a9b58ec6b313a1672dfd9d6ec0e0dca Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Tue, 10 Feb 2026 20:10:48 +0000 Subject: [PATCH 36/46] revert: test changes --- tests/ui/ReportActionComposeTest.tsx | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/tests/ui/ReportActionComposeTest.tsx b/tests/ui/ReportActionComposeTest.tsx index 27955c8b28e5..a9eecd42f649 100644 --- a/tests/ui/ReportActionComposeTest.tsx +++ b/tests/ui/ReportActionComposeTest.tsx @@ -237,7 +237,7 @@ describe('ReportActionCompose Integration Tests', () => { }); it('should send when length is within the limit', async () => { - const {unmount} = renderReportActionCompose(); + renderReportActionCompose(); const composer = screen.getByTestId('composer'); // Given a message that is within the length limit @@ -254,13 +254,10 @@ describe('ReportActionCompose Integration Tests', () => { // Then the message should be sent expect(mockForceClearInput).toHaveBeenCalledTimes(1); - - unmount(); - await waitForBatchedUpdatesWithAct(); }); it('should not send when length exceeds the limit', async () => { - const {unmount} = renderReportActionCompose(); + renderReportActionCompose(); const composer = screen.getByTestId('composer'); // Given a message that is over the length limit @@ -275,9 +272,6 @@ describe('ReportActionCompose Integration Tests', () => { // And the error should be displayed expect(screen.getByText('composer.commentExceededMaxLength')).toBeOnTheScreen(); - - unmount(); - await waitForBatchedUpdatesWithAct(); }); }); }); From 92c335d6548a6d13b8fda199292c345870b26d21 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Tue, 10 Feb 2026 22:02:48 +0000 Subject: [PATCH 37/46] refactor: update ref type --- .../ComposerWithSuggestions/ComposerWithSuggestions.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx b/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx index 323ab7f5d618..ccd00011c507 100644 --- a/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx +++ b/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx @@ -1,6 +1,6 @@ import {useIsFocused, useNavigation, useRoute} from '@react-navigation/native'; import lodashDebounce from 'lodash/debounce'; -import type {ForwardedRef, RefObject} from 'react'; +import type {RefObject} from 'react'; import React, {memo, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState} from 'react'; import type {BlurEvent, LayoutChangeEvent, MeasureInWindowOnSuccessCallback, TextInput, TextInputContentSizeChangeEvent, TextInputKeyPressEvent, TextInputScrollEvent} from 'react-native'; import {DeviceEventEmitter, InteractionManager, NativeModules, StyleSheet, View} from 'react-native'; @@ -142,7 +142,7 @@ type ComposerWithSuggestionsProps = Partial & didHideComposerInput?: boolean; /** Reference to the outer element */ - ref?: ForwardedRef; + ref?: RefObject; }; type SwitchToCurrentReportProps = { From f82db7a4467ce64e7a9175fe82483fa6b1d93a2a Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Tue, 10 Feb 2026 22:02:59 +0000 Subject: [PATCH 38/46] refactor: rename state --- .../ComposerWithSuggestions.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx b/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx index ccd00011c507..7014736e74c8 100644 --- a/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx +++ b/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx @@ -288,7 +288,7 @@ function ComposerWithSuggestions({ const [selection, setSelection] = useState(() => ({start: value.length, end: value.length, positionX: 0, positionY: 0})); - const [defaultComposerHeight, setDefaultComposerHeight] = useState(null); + const [composerHeightAfterClear, setDefaultComposerHeight] = useState(null); const emptyComposerHeightRef = useRef(null); const textInputRef = useRef(null); @@ -569,11 +569,11 @@ function ComposerWithSuggestions({ * After that, the composer will adjust it's height based on it's parent flex layout. */ const clearComposerHeight = useCallback(() => { - if (defaultComposerHeight == null) { + if (composerHeightAfterClear == null) { return; } setDefaultComposerHeight(null); - }, [defaultComposerHeight]); + }, [composerHeightAfterClear]); const onChangeText = useCallback( (commentValue: string) => { @@ -891,7 +891,7 @@ function ComposerWithSuggestions({ return ( <> { isTouchEndedRef.current = true; }} @@ -909,7 +909,7 @@ function ComposerWithSuggestions({ style={[ styles.textInputCompose, isComposerFullSize ? styles.textInputFullCompose : styles.textInputCollapseCompose, - defaultComposerHeight != null && {height: defaultComposerHeight}, + composerHeightAfterClear != null && {height: composerHeightAfterClear}, ]} maxLines={maxComposerLines} onFocus={handleFocus} From 331c0d508b7c860bb0876180b270d497201ab8df Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Tue, 10 Feb 2026 22:10:56 +0000 Subject: [PATCH 39/46] refactor: `addAttachment` callback --- .../report/ReportActionCompose/ReportActionCompose.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx b/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx index a1d35b8522e4..7d4869c48094 100644 --- a/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx +++ b/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx @@ -310,12 +310,14 @@ function ReportActionCompose({ const addAttachment = useCallback((file: FileObject | FileObject[]) => { attachmentFileRef.current = file; - const clear = composerRef.current?.clearWorklet; - if (!clear) { - throw new Error('The composerRef.clear function is not set yet. This should never happen, and indicates a developer error.'); + + const clearWorklet = composerRef.current?.clearWorklet; + + if (!clearWorklet) { + throw new Error('The composerRef.clearWorklet function is not set yet. This should never happen, and indicates a developer error.'); } - scheduleOnUI(clear); + scheduleOnUI(clearWorklet); }, []); /** From 9ffcb7456cd6e9a00ab9e407ac8f761214677cea Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Tue, 10 Feb 2026 22:11:09 +0000 Subject: [PATCH 40/46] refactor: improve ref type --- .../inbox/report/ReportActionCompose/ReportActionCompose.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx b/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx index 7d4869c48094..cbd097fc27d0 100644 --- a/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx +++ b/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx @@ -197,7 +197,7 @@ function ReportActionCompose({ const icons = useMemoizedLazyExpensifyIcons(['MessageInABottle']); const suggestionsRef = useRef(null); - const composerRef = useRef(undefined); + const composerRef = useRef(null); const reportParticipantIDs = useMemo( () => Object.keys(report?.participants ?? {}) @@ -576,7 +576,7 @@ function ReportActionCompose({ /> { - composerRef.current = ref ?? undefined; + composerRef.current = ref; composerRefShared.set({ clearWorklet: ref?.clearWorklet, }); From 589d991caa58cd40f2bd80cff74340427917e2ad Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Tue, 10 Feb 2026 22:15:50 +0000 Subject: [PATCH 41/46] fix: ref type --- .../ComposerWithSuggestions/ComposerWithSuggestions.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx b/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx index 7014736e74c8..dcfde0767187 100644 --- a/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx +++ b/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx @@ -1,6 +1,6 @@ import {useIsFocused, useNavigation, useRoute} from '@react-navigation/native'; import lodashDebounce from 'lodash/debounce'; -import type {RefObject} from 'react'; +import type {Ref, RefObject} from 'react'; import React, {memo, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState} from 'react'; import type {BlurEvent, LayoutChangeEvent, MeasureInWindowOnSuccessCallback, TextInput, TextInputContentSizeChangeEvent, TextInputKeyPressEvent, TextInputScrollEvent} from 'react-native'; import {DeviceEventEmitter, InteractionManager, NativeModules, StyleSheet, View} from 'react-native'; @@ -142,7 +142,7 @@ type ComposerWithSuggestionsProps = Partial & didHideComposerInput?: boolean; /** Reference to the outer element */ - ref?: RefObject; + ref?: Ref; }; type SwitchToCurrentReportProps = { From c6c0e6105db8aa3f4b129bc681ca81771414bda1 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Tue, 10 Feb 2026 22:15:58 +0000 Subject: [PATCH 42/46] refactor: order of functions --- .../ComposerWithSuggestions/ComposerWithSuggestions.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx b/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx index dcfde0767187..631f94c52f7f 100644 --- a/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx +++ b/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx @@ -784,9 +784,9 @@ function ComposerWithSuggestions({ focus, replaceSelectionWithText, isFocused: () => !!textInputRef.current?.isFocused(), + getCurrentText, clearWorklet, resetHeight, - getCurrentText, }), [blur, focus, replaceSelectionWithText, clearWorklet, resetHeight, getCurrentText], ); From 9d91f16dfbcb0c5e7d165b0412b57158e39690bb Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Tue, 10 Feb 2026 22:16:10 +0000 Subject: [PATCH 43/46] refactor: hook deps --- .../ReportActionCompose/ReportActionCompose.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx b/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx index cbd097fc27d0..3a9bb8ab7cdc 100644 --- a/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx +++ b/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx @@ -367,7 +367,18 @@ function ReportActionCompose({ onSubmit(newCommentTrimmed); } }, - [isConciergeChat, kickoffWaitingIndicator, transactionThreadReport, report, reportID, ancestors, personalDetail.timezone, onSubmit, isInSidePanel], + [ + isConciergeChat, + kickoffWaitingIndicator, + transactionThreadReport, + report, + reportID, + ancestors, + currentUserPersonalDetails.accountID, + personalDetail.timezone, + isInSidePanel, + onSubmit, + ], ); const onTriggerAttachmentPicker = useCallback(() => { From df874bb9caab5667d12265326813199ad4a6c4bf Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Tue, 10 Feb 2026 22:18:34 +0000 Subject: [PATCH 44/46] refactor: worklets --- .../ReportActionCompose/ReportActionCompose.tsx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx b/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx index 3a9bb8ab7cdc..450520c74e98 100644 --- a/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx +++ b/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx @@ -467,16 +467,15 @@ function ReportActionCompose({ setIsComposerFullSize(reportID, false); scheduleOnUI(() => { - const {clearWorklet: clearComposer} = composerRefShared.get(); + const {clearWorklet} = composerRefShared.get(); - if (!clearComposer) { - throw new Error('The composerRefShared.clear function is not set yet. This should never happen, and indicates a developer error.'); + if (!clearWorklet) { + throw new Error('The composerRef.clearWorklet function is not set yet. This should never happen, and indicates a developer error.'); } - // This will cause onCleared to be triggered where we actually send the message - clearComposer?.(); + clearWorklet?.(); }); - }, [isSendDisabled, debouncedValidate, composerRefShared, reportID]); + }, [isSendDisabled, debouncedValidate, reportID, composerRefShared]); onSubmitAction = handleSendMessage; From 60ce20dbbe800e0d1a767797ea85a62efb0f9fb8 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Tue, 10 Feb 2026 22:20:06 +0000 Subject: [PATCH 45/46] fix: failing test --- .../report/ReportActionCompose/ReportActionCompose.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx b/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx index 450520c74e98..54f82235396b 100644 --- a/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx +++ b/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx @@ -464,7 +464,9 @@ function ReportActionCompose({ } composerRef.current?.resetHeight(); - setIsComposerFullSize(reportID, false); + if (isComposerFullSize) { + setIsComposerFullSize(reportID, false); + } scheduleOnUI(() => { const {clearWorklet} = composerRefShared.get(); @@ -475,7 +477,7 @@ function ReportActionCompose({ clearWorklet?.(); }); - }, [isSendDisabled, debouncedValidate, reportID, composerRefShared]); + }, [isSendDisabled, debouncedValidate, isComposerFullSize, reportID, composerRefShared]); onSubmitAction = handleSendMessage; From 1c37b5453b784ca1e8f6323055e76158b2393ecf Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Tue, 10 Feb 2026 22:23:30 +0000 Subject: [PATCH 46/46] fix: remove unused style --- .../ComposerWithSuggestions/ComposerWithSuggestions.tsx | 2 +- src/styles/index.ts | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx b/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx index 631f94c52f7f..fee78bd6b41a 100644 --- a/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx +++ b/src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx @@ -891,7 +891,7 @@ function ComposerWithSuggestions({ return ( <> { isTouchEndedRef.current = true; }} diff --git a/src/styles/index.ts b/src/styles/index.ts index 222744af94ab..19f0acb9b69c 100644 --- a/src/styles/index.ts +++ b/src/styles/index.ts @@ -2160,10 +2160,6 @@ const staticStyles = (theme: ThemeColors) => flex: 4, }, - textInputComposeAfterClear: { - justifyContent: 'center', - }, - // composer padding should not be modified unless thoroughly tested against the cases in this PR: #12669 textInputComposeSpacing: { paddingVertical: 5,