Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix composer isn't auto focused when click reply in a thread #41402

Merged
merged 4 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
13 changes: 9 additions & 4 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4957,6 +4957,11 @@ function hasViolations(reportID: string, transactionViolations: OnyxCollection<T
return transactions.some((transaction) => TransactionUtils.hasViolation(transaction.transactionID, transactionViolations));
}

function isEmptyChat(report: OnyxEntry<Report>) {
const lastVisibleMessage = ReportActionsUtils.getLastVisibleMessage(report?.reportID ?? '');
return !report?.lastMessageText && !report?.lastMessageTranslationKey && !lastVisibleMessage.lastMessageText && !lastVisibleMessage.lastMessageTranslationKey;
}

/**
* Takes several pieces of data from Onyx and evaluates if a report should be shown in the option list (either when searching
* for reports or the reports shown in the LHN).
Expand Down Expand Up @@ -5034,8 +5039,7 @@ function shouldReportBeInOptionList({
if (hasDraftComment || requiresAttentionFromCurrentUser(report)) {
return true;
}
const lastVisibleMessage = ReportActionsUtils.getLastVisibleMessage(report.reportID);
const isEmptyChat = !report.lastMessageText && !report.lastMessageTranslationKey && !lastVisibleMessage.lastMessageText && !lastVisibleMessage.lastMessageTranslationKey;
const isEmptyChatValue = isEmptyChat(report);
const canHideReport = shouldHideReport(report, currentReportId);

// Include reports if they are pinned
Expand All @@ -5051,7 +5055,7 @@ function shouldReportBeInOptionList({
}

// Hide only chat threads that haven't been commented on (other threads are actionable)
if (isChatThread(report) && canHideReport && isEmptyChat) {
if (isChatThread(report) && canHideReport && isEmptyChatValue) {
return false;
}

Expand All @@ -5072,7 +5076,7 @@ function shouldReportBeInOptionList({
}

// Hide chats between two users that haven't been commented on from the LNH
if (excludeEmptyChats && isEmptyChat && isChatReport(report) && !isChatRoom(report) && !isPolicyExpenseChat(report) && canHideReport) {
if (excludeEmptyChats && isEmptyChatValue && isChatReport(report) && !isChatRoom(report) && !isPolicyExpenseChat(report) && canHideReport) {
return false;
}

Expand Down Expand Up @@ -6631,6 +6635,7 @@ export {
isDM,
isDefaultRoom,
isDeprecatedGroupDM,
isEmptyChat,
isExpenseReport,
isExpenseRequest,
isExpensifyOnlyParticipantInReport,
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/ReportScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ function ReportScreen({

const {reportPendingAction, reportErrors} = ReportUtils.getReportOfflinePendingActionAndErrors(report);
const screenWrapperStyle: ViewStyle[] = [styles.appContent, styles.flex1, {marginTop: viewportOffsetTop}];
const isEmptyChat = useMemo((): boolean => reportActions.length === 0, [reportActions]);
const isEmptyChat = useMemo(() => ReportUtils.isEmptyChat(report), [report]);
const isOptimisticDelete = report.statusNum === CONST.REPORT.STATUS_NUM.CLOSED;
const isLinkedMessageAvailable = useMemo(
(): boolean => sortedAllReportActions.findIndex((obj) => String(obj.reportActionID) === String(reportActionIDFromRoute)) > -1,
Expand Down
Loading