Skip to content

Commit 81d455f

Browse files
authored
Merge pull request Expensify#66852 from huult/64012-improve-navigation-expense-from-reports
Improve navigation behavior when opening expenses from report
2 parents f7a147e + e3a1536 commit 81d455f

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

src/pages/home/report/ReportActionsList.tsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ function ReportActionsList({
181181
const [emojiReactions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS_REACTIONS}`, {canBeMissing: true});
182182
const [userBillingFundID] = useOnyx(ONYXKEYS.NVP_BILLING_FUND_ID, {canBeMissing: true});
183183
const [isScrollToBottomEnabled, setIsScrollToBottomEnabled] = useState(false);
184+
const [shouldScrollToEndAfterLayout, setShouldScrollToEndAfterLayout] = useState(false);
184185
const [actionIdToHighlight, setActionIdToHighlight] = useState('');
185186

186187
useEffect(() => {
@@ -396,9 +397,19 @@ function ReportActionsList({
396397
if (linkedReportActionID) {
397398
return;
398399
}
400+
401+
const shouldScrollToEnd = (isExpenseReport(report) || isTransactionThread(parentReportAction)) && isSearchTopmostFullScreenRoute();
402+
403+
if (shouldScrollToEnd) {
404+
setShouldScrollToEndAfterLayout(true);
405+
}
406+
399407
InteractionManager.runAfterInteractions(() => {
400408
setIsFloatingMessageCounterVisible(false);
401-
reportScrollManager.scrollToBottom();
409+
410+
if (!shouldScrollToEnd) {
411+
reportScrollManager.scrollToBottom();
412+
}
402413
});
403414
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
404415
}, []);
@@ -709,8 +720,12 @@ function ReportActionsList({
709720
reportScrollManager.scrollToBottom();
710721
setIsScrollToBottomEnabled(false);
711722
}
723+
if (shouldScrollToEndAfterLayout) {
724+
reportScrollManager.scrollToEnd();
725+
setShouldScrollToEndAfterLayout(false);
726+
}
712727
},
713-
[isScrollToBottomEnabled, onLayout, reportScrollManager],
728+
[isScrollToBottomEnabled, onLayout, reportScrollManager, shouldScrollToEndAfterLayout],
714729
);
715730

716731
const retryLoadNewerChatsError = useCallback(() => {

0 commit comments

Comments
 (0)