You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[$250] Dev - Welcome header is showing after the contents #85487
BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributorHelp WantedApply this label when an issue is open to proposals by contributors
Version Number: Reproducible in staging?: Needs Reproduction (Unable to reproduce) Reproducible in production?: Needs Reproduction If this was caught during regression testing, add the test name, ID and link from BrowserStack: Email or phone of affected tester (no customers): Logs:https://stackoverflow.com/c/expensify/questions/4856 Expensify/Expensify Issue URL: Issue reported by:@ShridharGoel Slack conversation (hyperlinked to channel name): #Expensify Bugs
Action Performed:
Create a new workspace
Navigate to workspace chat
Create a manual expense
Observe the welcome message
Expected Result:
Welcome header should show before all the messages
Actual Result:
Welcome header is showing after the messages (Expense report)
Workaround:
Unknown
Platforms:
Select the officially supported platforms where the issue was reproduced:
Please re-state the problem that we are trying to solve in this issue.
When a user creates a new workspace, navigates to the workspace chat, and creates a manual expense, the welcome header (avatars + "This is the beginning of your chat with...") appears below the expense report preview instead of at the top of the chat.
What is the root cause of that problem?
The workspace chat uses ReportActionsList with an InvertedFlatList where actions are sorted descending (newest first). The CREATED action (welcome header) is guaranteed to sort last in this array via explicit logic in getSortedReportActions (ReportActionsUtils.ts:644-646), which in the inverted list places it at the visual top.
However, the issue occurs because of a scroll positioning race during the optimistic expense creation flow. When the REPORT_PREVIEW action is optimistically added to the workspace chat:
ReportActionsList receives the updated sortedVisibleReportActions with CREATED at the end (index 1) and REPORT_PREVIEW at the start (index 0)
The list auto-scrolls to show the newest content via shouldScrollToEndAfterLayout (ReportActionsList.tsx:819). For workspace chats, hasCreatedActionAdded is false (because shouldAddCreatedAction at ReportActionsView.tsx:167 only generates optimistic CREATED actions for money request/invoice reports, not workspace chats), so the condition !hasCreatedActionAdded is always true
This causes reportScrollManager.scrollToEnd() to fire, which in an inverted FlatList scrolls to show the oldest content (the CREATED/welcome header) at the bottom of the viewport instead of anchoring the newest message at the bottom
The root issue is that shouldScrollToEndAfterLayout combined with !hasCreatedActionAdded being always true for workspace chats causes an unwanted scrollToEnd() call after the expense is created, placing the welcome header at the bottom of the visible area with the expense report above it.
Additionally, the scrollToEnd behavior is gated by !hasCreatedActionAdded || isOffline at lines 409 and 819 of ReportActionsList.tsx. Since workspace chats always have hasCreatedActionAdded = false, this scroll behavior fires unconditionally after layout, disrupting the expected scroll position.
What changes do you think we should make in order to solve the problem?
The fix should ensure that after an expense is created in a workspace chat, the list maintains proper scroll position with the welcome header at the top and the newest message (expense) visible at the bottom.
Specifically, in ReportActionsList.tsx, the onTrackScrolling callback and onLayoutInner callback should account for the fact that workspace chats (and other non-money-request reports) never have hasCreatedActionAdded = true. The shouldScrollToEndAfterLayout logic should be refined to not trigger scrollToEnd() when the list already contains a CREATED action in the visible actions (i.e., when sortedVisibleReportActions already includes a CREATED action from Onyx rather than an optimistically added one).
The condition at lines 409 and 819 could be updated from:
to also check whether the CREATED action already exists in the visible actions, preventing the scroll when the welcome header is already present and properly positioned.
What alternative solutions did you explore? (Optional)
Making shouldAddCreatedAction true for workspace chats: This would mean generating an optimistic CREATED action for workspace chats too, which would make hasCreatedActionAdded properly transition from true to false. However, workspace chats always have their CREATED action stored in Onyx from workspace creation, so generating another one would be redundant and could cause duplicate CREATED actions.
Adjusting sort logic: The sort logic in getSortedReportActions is already correct — CREATED is explicitly pinned to the oldest position regardless of timestamp. The issue is not with data ordering but with scroll behavior after layout.
Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, @MelvinBot to refine this analysis, or explain why you are rejecting Melvin's proposal.
changed the title [-]Dev - Welcome header is showing after the contents[/-][+][$250] Dev - Welcome header is showing after the contents[/+]on Mar 17, 2026
Please re-state the problem that we are trying to solve in this issue.
In the expense report flow triggered from a workspace chat, the welcome header (CREATED action) can appear after the expense content instead of before it. This makes the report look out of order right after creation.
What is the root cause of that problem?
The initial "focus-to-top" flow for money request/invoice reports depends on shouldScrollToEndAfterLayout. That flag starts as true for these report types, and scrollToEnd() is expected to run once to place the oldest CREATED action at the top.
However, the same gate is also used in onTrackScrolling to immediately set that flag to false when !hasCreatedActionAdded. For reports that already have a CREATED action (so hasCreatedActionAdded is false), an early mount scroll event can clear the flag before onLayoutInner executes the scrollToEnd() call. That race leaves the list at the default position, so the welcome header can render below newer content.
What changes do you think we should make in order to solve the problem?
Make the initial scrollToEnd() execution authoritative instead of relying on a scroll event race:
Track whether the one-time initial scrollToEnd() was actually scheduled/executed (e.g., a ref).
Set shouldScrollToEndAfterLayout(false) immediately after scheduling/executing that one-time scroll.
Stop clearing shouldScrollToEndAfterLayout in onTrackScrolling before the initial programmatic scroll has run.
Keep onTrackScrolling as a cleanup path only after the initial mount scroll is completed.
Keep the existing prevHasCreatedActionAdded && !hasCreatedActionAdded transition behavior for optimistic-created-action flows, but decouple it from the "already-has-created-action" path so both scenarios are deterministic.
This removes the ordering race and ensures the welcome header remains above report contents on first render.
What alternative solutions did you explore? (Optional)
Always inject an optimistic CREATED action for these reports.
Rejected because it can duplicate CREATED behavior and adds unnecessary synthetic actions when a real CREATED already exists.
Change report-action sorting rules.
Rejected because sorting is already designed to keep CREATED as the oldest display action; the failure is in initial scroll state timing, not sort order.
Please re-state the problem that we are trying to solve in this issue.
When a user creates a new workspace, navigates to the workspace chat, and creates a manual expense, the welcome header (CREATED action) appears below the expense report preview instead of above it.
What is the root cause of that problem?
Both existing proposals attribute this to the shouldScrollToEndAfterLayout / scrollToEnd() logic in ReportActionsList.tsx. However, that analysis does not hold for workspace chats. Here is why:
In ReportActionsList.tsx (line 237), shouldFocusToTopOnMount is computed as:
A workspace chat is neither a transaction thread nor a money request/invoice report. So shouldFocusToTopOnMount is false, which means shouldScrollToEndAfterLayout is initialized to false (line 239) and is never set to true. The scroll-to-end gates at lines 409, 531, 819, and 911 all check shouldScrollToEndAfterLayout and therefore never fire for workspace chats. The justifyContentEnd style at line 920 is also not applied.
The actual root cause is in the scrollToBottomForCurrentUserAction callback (lines 559-596). When the user creates an expense from the workspace chat, a REPORT_PREVIEW action is optimistically added. The new-action event fires this callback:
At line 577, it looks up the REPORT_PREVIEW's index in sortedVisibleReportActionsRef.current. Due to the InteractionManager.runAfterInteractions delay, the ref may not yet reflect the updated data (the ref is synced via useEffect at line 555-557, which also runs asynchronously after render). If the ref still holds the old array (just CREATED), findIndex returns -1.
At line 578-586, for a REPORT_PREVIEW with index > 0 false (index is 0 or -1), it falls through to scrollToBottom() (offset 0). It then calls setIsScrollToBottomEnabled(true) at line 595.
The setIsScrollToBottomEnabled(true) state update triggers a re-render. On the next layout (onLayoutInner, line 812-826), scrollToBottom() is called again.
Here is the problem: between the optimistic data update (step 1) and the final scroll (step 3), the InvertedFlatList's maintainVisibleContentPosition is undefined for this scenario (line 119-134 of useFlatListScrollKey.ts — it is only active when initialScrollKey is set). Without maintainVisibleContentPosition, when a new item is prepended to the data array (REPORT_PREVIEW is at index 0, prepended before CREATED at index 1), the FlatList does not adjust its scroll offset to account for the new item's height. The content shifts, and the subsequent scrollToBottom() at offset 0 anchors the viewport to the wrong visual position — showing the CREATED action at the bottom of the viewport instead of the top.
This is a timing-dependent issue that manifests specifically when: (a) the report is a workspace chat (no shouldScrollToEndAfterLayout), (b) the list has very few items (1 CREATED action), and (c) the viewport is taller than the content, so the content shift from prepending the REPORT_PREVIEW is noticeable.
What changes do you think we should make in order to solve the problem?
The fix should be in the scrollToBottomForCurrentUserAction callback in ReportActionsList.tsx. When a REPORT_PREVIEW action is added to a non-money-request, non-transaction-thread report (like a workspace chat), the callback should not call scrollToBottom() immediately. Instead, it should let the FlatList settle with the new data first, then scroll.
Specifically, in scrollToBottomForCurrentUserAction (lines 578-586), when the action is a REPORT_PREVIEW and the report is not a money request or transaction thread report, delay the scroll until after the FlatList has re-rendered with the new data by waiting for the next requestAnimationFrame after the state update, rather than scrolling immediately and relying on setIsScrollToBottomEnabled for a follow-up scroll that races with the content layout.
Remove the setIsScrollToBottomEnabled(true) call at line 595 for the REPORT_PREVIEW case and instead use a single deferred scrollToBottom() via requestAnimationFrame that fires after the FlatList has incorporated the new item into its layout. This eliminates the double-scroll race between scrollToBottomForCurrentUserAction and onLayoutInner.
What alternative solutions did you explore? (Optional)
Enabling maintainVisibleContentPosition for all inverted lists regardless of initialScrollKey. This would prevent the content shift when items are prepended, but it would change scrolling behavior globally and could introduce regressions in other report types that rely on the current prepend-without-adjustment behavior.
Adding workspace chats to the shouldFocusToTopOnMount check so they also get the scrollToEnd flow. This would work but is semantically wrong — workspace chats do not need the money-request-report-style "scroll to oldest action" behavior on mount.
📣 @janekissington! 📣
Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Please follow these steps:
Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>
Please re-state the problem that we are trying to solve in this issue.
When a user creates a manual expense from a workspace chat, the welcome header can appear after the expense content instead of before it. The chat content is rendered in the wrong visual order, so the beginning-of-chat section is no longer anchored at the top as expected.
What is the root cause of that problem?
The issue is in the web render path for the inverted report actions list.
ReportActionsList renders its chat body through an InvertedFlatList, and that list uses ActionSheetAwareScrollView as its custom scroll component. After the revert of PR #82507 , the web implementation of ActionSheetAwareScrollView no longer applies the reversed content-container layout that the inverted report-actions list relied on for correct visual ordering in some report flows.
As a result, short report-action lists such as a workspace chat with a CREATED action and a newly added expense preview can render with the welcome header visually appearing after the newer content.
At the same time, restoring the old reversed content-container behavior globally would reintroduce the earlier expense modal regression, so the problem is not just “missing reverse layout” but “missing scoped reverse layout for the correct report-action flows.”
What changes do you think we should make in order to solve the problem?
We should make the reverse content-container behavior explicit and opt-in instead of applying it globally in the shared scroll wrapper.
Specifically:
Add a prop to ActionSheetAwareScrollView to control whether the content container should use reversed layout on web.
Keep the default behavior non-reversed so shared usages do not inherit this layout unexpectedly.
In ReportActionsList, pass that prop only for report-action list flows that need the reversed web layout to preserve correct visual ordering.
Do not enable that reversed layout for the “focus to top on mount” flows, since those are the flows that were previously affected by the right-side expense modal regression.
Solution code
diff --git a/src/components/ActionSheetAwareScrollView/index.tsx b/src/components/ActionSheetAwareScrollView/index.tsx
index 40814916396..8c4f12a66df 100644
--- a/src/components/ActionSheetAwareScrollView/index.tsx+++ b/src/components/ActionSheetAwareScrollView/index.tsx@@ -2,18 +2,25 @@
// On all other platforms, the action sheet is implemented using the Animated.ScrollView
import React from 'react';
import Reanimated from 'react-native-reanimated';
+import useThemeStyles from '@hooks/useThemeStyles';
import {Actions, ActionSheetAwareScrollViewProvider, useActionSheetAwareScrollViewActions, useActionSheetAwareScrollViewState} from './ActionSheetAwareScrollViewContext';
import type {ActionSheetAwareScrollViewProps, RenderActionSheetAwareScrollViewComponent} from './types';
import useActionSheetAwareScrollViewRef from './useActionSheetAwareScrollViewRef';
-function ActionSheetAwareScrollView({children, ref, ...restProps}: ActionSheetAwareScrollViewProps) {+function ActionSheetAwareScrollView({children, ref, shouldReverseContentContainer = false, ...restProps}: ActionSheetAwareScrollViewProps) {
const {onRef} = useActionSheetAwareScrollViewRef(ref);
+ const styles = useThemeStyles();
return (
<Reanimated.ScrollView
// eslint-disable-next-line react/jsx-props-no-spreading
{...restProps}
ref={onRef}
+ contentContainerStyle={[+ restProps.contentContainerStyle,+ shouldReverseContentContainer ? (restProps.horizontal ? styles.flexRowReverse : styles.flexColumnReverse) : undefined,+ shouldReverseContentContainer ? styles.justifyContentEnd : undefined,+ ]}
>
{children}
</Reanimated.ScrollView>
diff --git a/src/components/ActionSheetAwareScrollView/types.ts b/src/components/ActionSheetAwareScrollView/types.ts
index bad0eb8fe65..93ce2f2a66a 100644
--- a/src/components/ActionSheetAwareScrollView/types.ts+++ b/src/components/ActionSheetAwareScrollView/types.ts@@ -30,6 +30,7 @@ type ActionSheetAwareScrollViewHandle = ScrollView | Reanimated.ScrollView;
type ActionSheetAwareScrollViewProps = ScrollViewProps & {
ref?: Ref<ActionSheetAwareScrollViewHandle>;
+ shouldReverseContentContainer?: boolean;
};
type RenderActionSheetAwareScrollViewComponent = (props: ActionSheetAwareScrollViewProps) => React.ReactElement<ScrollViewProps>;
diff --git a/src/pages/inbox/report/ReportActionsList.tsx b/src/pages/inbox/report/ReportActionsList.tsx
index 215d63b033f..f5f00cad478 100644
--- a/src/pages/inbox/report/ReportActionsList.tsx+++ b/src/pages/inbox/report/ReportActionsList.tsx@@ -897,6 +897,15 @@ function ReportActionsList({
loadOlderChats(false);
}, [loadOlderChats]);
+ const renderScrollComponent = useCallback(+ (props: Parameters<typeof renderActionSheetAwareScrollView>[0]) =>+ renderActionSheetAwareScrollView({+ ...props,+ shouldReverseContentContainer: !shouldFocusToTopOnMount,+ }),+ [shouldFocusToTopOnMount],+ );+
return (
<>
<FloatingMessageCounter
@@ -916,7 +925,7 @@ function ReportActionsList({
style={[styles.overscrollBehaviorContain, shouldScrollToEndAfterLayout && styles.flex0]}
data={sortedVisibleReportActions}
renderItem={renderItem}
- renderScrollComponent={renderActionSheetAwareScrollView}+ renderScrollComponent={renderScrollComponent}
contentContainerStyle={[styles.chatContentScrollView, shouldFocusToTopOnMount ? styles.justifyContentEnd : undefined]}
shouldHideContent={shouldScrollToEndAfterLayout}
shouldDisableVisibleContentPosition={shouldScrollToEndAfterLayout}
This keeps the fix local to the report-actions list behavior that needs it, while avoiding another global regression in expense-related layouts.
What alternative solutions did you explore? (Optional)
Restore the previous reversed layout globally in ActionSheetAwareScrollView.
This was rejected because it would likely reintroduce the earlier web regression where the right-side expense modal content was pushed into the wrong position.
Fix the issue with additional wrapper justifyContent or flex adjustments in report screens.
This was rejected because it only treats the symptom and does not address the incorrect content ordering introduced in the shared inverted-list scroll path.
Special-case the workspace chat layout outside the scroll component.
This was rejected because the issue belongs to the inverted report-actions rendering path, and solving it there is cleaner and less fragile than patching one report type downstream.
📣 @junagent! 📣
Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Please follow these steps:
Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>
📣 @victorjzq! 📣
Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Please follow these steps:
Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>
My read of the problem: On the Dev environment, the Welcome header renders after the main page content, causing a visual flash/reorder. This is a rendering order issue — the header has an async data dependency (Onyx key or API response) that delays its appearance while the content renders synchronously.
Implementation plan:
Step 1: Locate the Welcome header component and its parent screen — inspect what data dependencies cause the header to conditionally render (Onyx keys, loading states, session data)
Step 2: Fix the rendering order by either: (a) blocking content render until header data is ready using a loading gate, or (b) rendering the header skeleton/placeholder immediately so it occupies its correct position while data loads
Step 3: Test on both web and mobile in the Dev environment to confirm the header renders before or simultaneously with content, with no visual reordering
Relevant skills: TypeScript, React Native, Onyx state management, Expensify patterns, 8 years full-stack. Commitment: Available now, deliver in 2-3 days.
BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributorHelp WantedApply this label when an issue is open to proposals by contributors
Activity
MelvinBot commentedon Mar 17, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a user creates a new workspace, navigates to the workspace chat, and creates a manual expense, the welcome header (avatars + "This is the beginning of your chat with...") appears below the expense report preview instead of at the top of the chat.
What is the root cause of that problem?
The workspace chat uses
ReportActionsListwith anInvertedFlatListwhere actions are sorted descending (newest first). The CREATED action (welcome header) is guaranteed to sort last in this array via explicit logic ingetSortedReportActions(ReportActionsUtils.ts:644-646), which in the inverted list places it at the visual top.However, the issue occurs because of a scroll positioning race during the optimistic expense creation flow. When the REPORT_PREVIEW action is optimistically added to the workspace chat:
ReportActionsListreceives the updatedsortedVisibleReportActionswith CREATED at the end (index 1) and REPORT_PREVIEW at the start (index 0)shouldScrollToEndAfterLayout(ReportActionsList.tsx:819). For workspace chats,hasCreatedActionAddedisfalse(becauseshouldAddCreatedActionatReportActionsView.tsx:167only generates optimistic CREATED actions for money request/invoice reports, not workspace chats), so the condition!hasCreatedActionAddedis alwaystruereportScrollManager.scrollToEnd()to fire, which in an inverted FlatList scrolls to show the oldest content (the CREATED/welcome header) at the bottom of the viewport instead of anchoring the newest message at the bottomThe root issue is that
shouldScrollToEndAfterLayoutcombined with!hasCreatedActionAddedbeing alwaystruefor workspace chats causes an unwantedscrollToEnd()call after the expense is created, placing the welcome header at the bottom of the visible area with the expense report above it.Additionally, the
scrollToEndbehavior is gated by!hasCreatedActionAdded || isOfflineat lines 409 and 819 ofReportActionsList.tsx. Since workspace chats always havehasCreatedActionAdded = false, this scroll behavior fires unconditionally after layout, disrupting the expected scroll position.What changes do you think we should make in order to solve the problem?
The fix should ensure that after an expense is created in a workspace chat, the list maintains proper scroll position with the welcome header at the top and the newest message (expense) visible at the bottom.
Specifically, in
ReportActionsList.tsx, theonTrackScrollingcallback andonLayoutInnercallback should account for the fact that workspace chats (and other non-money-request reports) never havehasCreatedActionAdded = true. TheshouldScrollToEndAfterLayoutlogic should be refined to not triggerscrollToEnd()when the list already contains a CREATED action in the visible actions (i.e., whensortedVisibleReportActionsalready includes a CREATED action from Onyx rather than an optimistically added one).The condition at lines 409 and 819 could be updated from:
to also check whether the CREATED action already exists in the visible actions, preventing the scroll when the welcome header is already present and properly positioned.
What alternative solutions did you explore? (Optional)
Making
shouldAddCreatedActiontrue for workspace chats: This would mean generating an optimistic CREATED action for workspace chats too, which would makehasCreatedActionAddedproperly transition fromtruetofalse. However, workspace chats always have their CREATED action stored in Onyx from workspace creation, so generating another one would be redundant and could cause duplicate CREATED actions.Adjusting sort logic: The sort logic in
getSortedReportActionsis already correct — CREATED is explicitly pinned to the oldest position regardless of timestamp. The issue is not with data ordering but with scroll behavior after layout.Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, @MelvinBot to refine this analysis, or explain why you are rejecting Melvin's proposal.
melvin-bot commentedon Mar 17, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @mkhutornyi (
External)melvin-bot commentedon Mar 17, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022033698750291113884
[-]Dev - Welcome header is showing after the contents[/-][+][$250] Dev - Welcome header is showing after the contents[/+]jainam884 commentedon Mar 17, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
In the expense report flow triggered from a workspace chat, the welcome header (CREATED action) can appear after the expense content instead of before it. This makes the report look out of order right after creation.
What is the root cause of that problem?
The initial "focus-to-top" flow for money request/invoice reports depends on
shouldScrollToEndAfterLayout. That flag starts astruefor these report types, andscrollToEnd()is expected to run once to place the oldest CREATED action at the top.However, the same gate is also used in
onTrackScrollingto immediately set that flag tofalsewhen!hasCreatedActionAdded. For reports that already have a CREATED action (sohasCreatedActionAddedisfalse), an early mount scroll event can clear the flag beforeonLayoutInnerexecutes thescrollToEnd()call. That race leaves the list at the default position, so the welcome header can render below newer content.App/src/pages/inbox/report/ReportActionsView.tsx
Line 127 in 1d43910
App/src/pages/inbox/report/ReportActionsList.tsx
Lines 366 to 367 in 1d43910
App/src/pages/inbox/report/ReportActionsList.tsx
Lines 762 to 765 in 1d43910
What changes do you think we should make in order to solve the problem?
scrollToEnd()execution authoritative instead of relying on a scroll event race:scrollToEnd()was actually scheduled/executed (e.g., a ref).shouldScrollToEndAfterLayout(false)immediately after scheduling/executing that one-time scroll.shouldScrollToEndAfterLayoutinonTrackScrollingbefore the initial programmatic scroll has run.onTrackScrollingas a cleanup path only after the initial mount scroll is completed.prevHasCreatedActionAdded && !hasCreatedActionAddedtransition behavior for optimistic-created-action flows, but decouple it from the "already-has-created-action" path so both scenarios are deterministic.This removes the ordering race and ensures the welcome header remains above report contents on first render.
What alternative solutions did you explore? (Optional)
janekissington commentedon Mar 17, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a user creates a new workspace, navigates to the workspace chat, and creates a manual expense, the welcome header (CREATED action) appears below the expense report preview instead of above it.
What is the root cause of that problem?
Both existing proposals attribute this to the
shouldScrollToEndAfterLayout/scrollToEnd()logic inReportActionsList.tsx. However, that analysis does not hold for workspace chats. Here is why:In
ReportActionsList.tsx(line 237),shouldFocusToTopOnMountis computed as:A workspace chat is neither a transaction thread nor a money request/invoice report. So
shouldFocusToTopOnMountisfalse, which meansshouldScrollToEndAfterLayoutis initialized tofalse(line 239) and is never set totrue. The scroll-to-end gates at lines 409, 531, 819, and 911 all checkshouldScrollToEndAfterLayoutand therefore never fire for workspace chats. ThejustifyContentEndstyle at line 920 is also not applied.The actual root cause is in the
scrollToBottomForCurrentUserActioncallback (lines 559-596). When the user creates an expense from the workspace chat, a REPORT_PREVIEW action is optimistically added. The new-action event fires this callback:At line 577, it looks up the REPORT_PREVIEW's index in
sortedVisibleReportActionsRef.current. Due to theInteractionManager.runAfterInteractionsdelay, the ref may not yet reflect the updated data (the ref is synced viauseEffectat line 555-557, which also runs asynchronously after render). If the ref still holds the old array (just CREATED),findIndexreturns-1.At line 578-586, for a REPORT_PREVIEW with
index > 0false (index is 0 or -1), it falls through toscrollToBottom()(offset 0). It then callssetIsScrollToBottomEnabled(true)at line 595.The
setIsScrollToBottomEnabled(true)state update triggers a re-render. On the next layout (onLayoutInner, line 812-826),scrollToBottom()is called again.Here is the problem: between the optimistic data update (step 1) and the final scroll (step 3), the InvertedFlatList's
maintainVisibleContentPositionisundefinedfor this scenario (line 119-134 ofuseFlatListScrollKey.ts— it is only active wheninitialScrollKeyis set). WithoutmaintainVisibleContentPosition, when a new item is prepended to the data array (REPORT_PREVIEW is at index 0, prepended before CREATED at index 1), the FlatList does not adjust its scroll offset to account for the new item's height. The content shifts, and the subsequentscrollToBottom()at offset 0 anchors the viewport to the wrong visual position — showing the CREATED action at the bottom of the viewport instead of the top.This is a timing-dependent issue that manifests specifically when: (a) the report is a workspace chat (no
shouldScrollToEndAfterLayout), (b) the list has very few items (1 CREATED action), and (c) the viewport is taller than the content, so the content shift from prepending the REPORT_PREVIEW is noticeable.What changes do you think we should make in order to solve the problem?
The fix should be in the
scrollToBottomForCurrentUserActioncallback inReportActionsList.tsx. When a REPORT_PREVIEW action is added to a non-money-request, non-transaction-thread report (like a workspace chat), the callback should not callscrollToBottom()immediately. Instead, it should let the FlatList settle with the new data first, then scroll.Specifically, in
scrollToBottomForCurrentUserAction(lines 578-586), when the action is a REPORT_PREVIEW and the report is not a money request or transaction thread report, delay the scroll until after the FlatList has re-rendered with the new data by waiting for the nextrequestAnimationFrameafter the state update, rather than scrolling immediately and relying onsetIsScrollToBottomEnabledfor a follow-up scroll that races with the content layout.Remove the
setIsScrollToBottomEnabled(true)call at line 595 for the REPORT_PREVIEW case and instead use a single deferredscrollToBottom()viarequestAnimationFramethat fires after the FlatList has incorporated the new item into its layout. This eliminates the double-scroll race betweenscrollToBottomForCurrentUserActionandonLayoutInner.What alternative solutions did you explore? (Optional)
Enabling
maintainVisibleContentPositionfor all inverted lists regardless ofinitialScrollKey. This would prevent the content shift when items are prepended, but it would change scrolling behavior globally and could introduce regressions in other report types that rely on the current prepend-without-adjustment behavior.Adding workspace chats to the
shouldFocusToTopOnMountcheck so they also get thescrollToEndflow. This would work but is semantically wrong — workspace chats do not need the money-request-report-style "scroll to oldest action" behavior on mount.melvin-bot commentedon Mar 17, 2026
📣 @janekissington! 📣
Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Please follow these steps:
Format:
janekissington commentedon Mar 17, 2026
Contributor details
Your Expensify account email: janekissington@outlook.com
Upwork Profile Link: https://www.upwork.com/freelancers/~0155095179172b2f4d
melvin-bot commentedon Mar 17, 2026
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
nabi-ebrahimi commentedon Mar 17, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a user creates a manual expense from a workspace chat, the welcome header can appear after the expense content instead of before it. The chat content is rendered in the wrong visual order, so the beginning-of-chat section is no longer anchored at the top as expected.
What is the root cause of that problem?
The issue is in the web render path for the inverted report actions list.
ReportActionsListrenders its chat body through anInvertedFlatList, and that list usesActionSheetAwareScrollViewas its custom scroll component. After the revert of PR #82507 , the web implementation ofActionSheetAwareScrollViewno longer applies the reversed content-container layout that the inverted report-actions list relied on for correct visual ordering in some report flows.As a result, short report-action lists such as a workspace chat with a CREATED action and a newly added expense preview can render with the welcome header visually appearing after the newer content.
At the same time, restoring the old reversed content-container behavior globally would reintroduce the earlier expense modal regression, so the problem is not just “missing reverse layout” but “missing scoped reverse layout for the correct report-action flows.”
What changes do you think we should make in order to solve the problem?
We should make the reverse content-container behavior explicit and opt-in instead of applying it globally in the shared scroll wrapper.
Specifically:
ActionSheetAwareScrollViewto control whether the content container should use reversed layout on web.ReportActionsList, pass that prop only for report-action list flows that need the reversed web layout to preserve correct visual ordering.Solution code
This keeps the fix local to the report-actions list behavior that needs it, while avoiding another global regression in expense-related layouts.
What alternative solutions did you explore? (Optional)
Restore the previous reversed layout globally in
ActionSheetAwareScrollView.This was rejected because it would likely reintroduce the earlier web regression where the right-side expense modal content was pushed into the wrong position.
Fix the issue with additional wrapper
justifyContentor flex adjustments in report screens.This was rejected because it only treats the symptom and does not address the incorrect content ordering introduced in the shared inverted-list scroll path.
Special-case the workspace chat layout outside the scroll component.
This was rejected because the issue belongs to the inverted report-actions rendering path, and solving it there is cleaner and less fragile than patching one report type downstream.
4 remaining items
melvin-bot commentedon Mar 19, 2026
📣 @junagent! 📣
Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Please follow these steps:
Format:
victorjzq commentedon Mar 19, 2026
/attempt #85487
melvin-bot commentedon Mar 19, 2026
📣 @victorjzq! 📣
Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Please follow these steps:
Format:
chengyixu commentedon Mar 21, 2026
Proposal
I'd like to work on this issue.
My read of the problem: On the Dev environment, the Welcome header renders after the main page content, causing a visual flash/reorder. This is a rendering order issue — the header has an async data dependency (Onyx key or API response) that delays its appearance while the content renders synchronously.
Implementation plan:
Relevant skills: TypeScript, React Native, Onyx state management, Expensify patterns, 8 years full-stack.
Commitment: Available now, deliver in 2-3 days.
chengyixu commentedon Mar 21, 2026
Proposal
I'd like to work on this issue.
Approach: Fix the Welcome header appearing after content has already loaded, preventing a layout flash/flicker.
Implementation:
Timeline: 2-3 hours
Stack: TypeScript, React Native, Onyx, familiar with Expensify patterns
Ready to start immediately.
melvin-bot commentedon Mar 23, 2026
@mkhutornyi Eep! 4 days overdue now. Issues have feelings too...
melvin-bot commentedon Mar 23, 2026
@mkhutornyi Eep! 4 days overdue now. Issues have feelings too...
MonilBhavsar commentedon Mar 24, 2026
Not reproducible https://expensify.slack.com/archives/C02NK2DQWUX/p1774319543044729
nabi-ebrahimi commentedon Mar 25, 2026
@MonilBhavsar, I still able to reproduce this on latest main, could you please re-open this thanks.
REC-20260325134601.mp4
mkhutornyi commentedon Mar 25, 2026
@nabi-ebrahimi did you fresh install npm?
nabi-ebrahimi commentedon Mar 25, 2026
@mkhutornyi I just checked the main again and pull the latest (about 30 commits) , now it is not reproducible for me