Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 12 additions & 27 deletions src/pages/home/report/ReportActionsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ import {
isExpenseReport,
isInvoiceReport,
isIOUReport,
isMoneyRequestReport,
isTaskReport,
isUnread,
} from '@libs/ReportUtils';
Expand Down Expand Up @@ -184,14 +183,9 @@ function ReportActionsList({
const [tryNewDot] = useOnyx(ONYXKEYS.NVP_TRY_NEW_DOT, {canBeMissing: false});
const isTryNewDotNVPDismissed = !!tryNewDot?.classicRedirect?.dismissed;
const [isScrollToBottomEnabled, setIsScrollToBottomEnabled] = useState(false);
const [shouldScrollToEndAfterLayout, setShouldScrollToEndAfterLayout] = useState(false);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No Issues Found

The revert restores the original state initialization which is correctly implemented. The state variable is properly initialized and managed.

const [actionIdToHighlight, setActionIdToHighlight] = useState('');

const isTransactionThreadReport = useMemo(() => isTransactionThread(parentReportAction), [parentReportAction]);
const isMoneyRequestOrInvoiceReport = useMemo(() => isMoneyRequestReport(report) || isInvoiceReport(report), [report]);
const shouldFocusToTopOnMount = useMemo(() => isTransactionThreadReport || isMoneyRequestOrInvoiceReport, [isMoneyRequestOrInvoiceReport, isTransactionThreadReport]);
const topReportAction = sortedVisibleReportActions.at(-1);
const [shouldScrollToEndAfterLayout, setShouldScrollToEndAfterLayout] = useState(shouldFocusToTopOnMount);

useEffect(() => {
const unsubscribe = Visibility.onVisibilityChange(() => {
setIsVisible(Visibility.isVisible());
Expand Down Expand Up @@ -348,9 +342,6 @@ function ReportActionsList({
onTrackScrolling: (event: NativeSyntheticEvent<NativeScrollEvent>) => {
scrollingVerticalOffset.current = event.nativeEvent.contentOffset.y;
onScroll?.(event);
if (shouldScrollToEndAfterLayout) {
setShouldScrollToEndAfterLayout(false);
}
},
});

Expand Down Expand Up @@ -400,10 +391,17 @@ function ReportActionsList({
return;
}

const shouldScrollToEnd =
(isExpenseReport(report) || isTransactionThread(parentReportAction)) && isSearchTopmostFullScreenRoute() && hasNewestReportAction && !unreadMarkerReportActionID;

if (shouldScrollToEnd) {
setShouldScrollToEndAfterLayout(true);
}

InteractionManager.runAfterInteractions(() => {
setIsFloatingMessageCounterVisible(false);

if (!shouldScrollToEndAfterLayout) {
if (!shouldScrollToEnd) {
reportScrollManager.scrollToBottom();
}
});
Expand Down Expand Up @@ -721,9 +719,8 @@ function ReportActionsList({
setIsScrollToBottomEnabled(false);
}
if (shouldScrollToEndAfterLayout) {
InteractionManager.runAfterInteractions(() => {
reportScrollManager.scrollToEnd();
});
reportScrollManager.scrollToEnd();
setShouldScrollToEndAfterLayout(false);
}
},
[isScrollToBottomEnabled, onLayout, reportScrollManager, shouldScrollToEndAfterLayout],
Expand Down Expand Up @@ -759,13 +756,6 @@ function ReportActionsList({
return <ReportActionsSkeletonView shouldAnimate={false} />;
}, [shouldShowSkeleton]);

const renderTopReportAction = () => (
<>
{!shouldShowReportRecipientLocalTime && !hideComposer ? <View style={[styles.stickToBottom, styles.appBG, styles.zIndex10, styles.height4]} /> : undefined}
<View style={styles.pt4}>{renderItem({item: topReportAction, index: sortedVisibleReportActions.length - 1} as ListRenderItemInfo<OnyxTypes.ReportAction>)}</View>
</>
);

const onStartReached = useCallback(() => {
if (!isSearchTopmostFullScreenRoute()) {
loadNewerChats(false);
Expand All @@ -790,7 +780,6 @@ function ReportActionsList({
style={[styles.flex1, !shouldShowReportRecipientLocalTime && !hideComposer ? styles.pb4 : {}]}
fsClass={reportActionsListFSClass}
>
{shouldScrollToEndAfterLayout && topReportAction ? renderTopReportAction() : undefined}
<InvertedFlatList
accessibilityLabel={translate('sidebarScreen.listOfChatMessages')}
ref={reportScrollManager.ref}
Expand All @@ -799,11 +788,7 @@ function ReportActionsList({
data={sortedVisibleReportActions}
renderItem={renderItem}
renderScrollComponent={renderActionSheetAwareScrollView}
contentContainerStyle={[
styles.chatContentScrollView,
shouldScrollToEndAfterLayout ? styles.opacity0 : styles.opacity1,
shouldFocusToTopOnMount ? styles.justifyContentEnd : undefined,
]}
contentContainerStyle={styles.chatContentScrollView}
keyExtractor={keyExtractor}
initialNumToRender={initialNumToRender}
onEndReached={onEndReached}
Expand Down
3 changes: 1 addition & 2 deletions src/pages/home/report/ReportActionsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ function ReportActionsView({
[getTransactionThreadReportActions],
);
const [transactionThreadReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReportID}`, {canBeMissing: true});
const [reportMetadata] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_METADATA}${report?.reportID}`, {canBeMissing: true, allowStaleData: true});
const [isLoadingApp] = useOnyx(ONYXKEYS.IS_LOADING_APP, {canBeMissing: true});
const prevTransactionThreadReport = usePrevious(transactionThreadReport);
const reportActionID = route?.params?.reportActionID;
Expand Down Expand Up @@ -292,7 +291,7 @@ function ReportActionsView({
}, [isTheFirstReportActionIsLinked]);

// Show skeleton while loading initial report actions when data is incomplete/missing and online
const shouldShowSkeletonForInitialLoad = isLoadingInitialReportActions && (isReportDataIncomplete || isMissingReportActions || !reportMetadata?.hasOnceLoadedReportActions) && !isOffline;
const shouldShowSkeletonForInitialLoad = isLoadingInitialReportActions && (isReportDataIncomplete || isMissingReportActions) && !isOffline;

// Show skeleton while the app is loading and we're online
const shouldShowSkeletonForAppLoad = isLoadingApp && !isOffline;
Expand Down
4 changes: 0 additions & 4 deletions src/styles/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3277,10 +3277,6 @@ const staticStyles = (theme: ThemeColors) =>
zIndex: 10,
},

height4: {
height: 16,
},

searchListContentContainerStyles: {
paddingTop: variables.searchListContentMarginTop,
},
Expand Down
Loading