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: edited subtask name not update in DM last message in LHN #48285

Merged
merged 6 commits into from
Sep 9, 2024
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
16 changes: 16 additions & 0 deletions src/components/LHNOptionsList/LHNOptionsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import * as ReportActionsUtils from '@libs/ReportActionsUtils';
import variables from '@styles/variables';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {PersonalDetails} from '@src/types/onyx';
import OptionRowLHNData from './OptionRowLHNData';
import type {LHNOptionsListProps, RenderItemProps} from './types';

Expand Down Expand Up @@ -148,6 +149,20 @@ function LHNOptionsList({style, contentContainerStyles, data, onSelectRow, optio
}
const lastReportActionTransaction = transactions?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${lastReportActionTransactionID}`];

// SidebarUtils.getOptionData in OptionRowLHNData does not get re-evaluated when the linked task report changes, so we have the lastMessageTextFromReport evaluation logic here
let lastActorDetails: Partial<PersonalDetails> | null =
itemFullReport?.lastActorAccountID && personalDetails?.[itemFullReport.lastActorAccountID] ? personalDetails[itemFullReport.lastActorAccountID] : null;
if (!lastActorDetails && lastReportAction) {
mkzie2 marked this conversation as resolved.
Show resolved Hide resolved
const lastActorDisplayName = lastReportAction?.person?.[0]?.text;
lastActorDetails = lastActorDisplayName
? {
displayName: lastActorDisplayName,
accountID: itemFullReport?.lastActorAccountID,
}
: null;
}
const lastMessageTextFromReport = OptionsListUtils.getLastMessageTextForReport(itemFullReport, lastActorDetails, itemPolicy);

return (
<OptionRowLHNData
reportID={reportID}
Expand All @@ -163,6 +178,7 @@ function LHNOptionsList({style, contentContainerStyles, data, onSelectRow, optio
receiptTransactions={transactions}
viewMode={optionMode}
isFocused={!shouldDisableFocusOptions}
lastMessageTextFromReport={lastMessageTextFromReport}
onSelectRow={onSelectRow}
preferredLocale={preferredLocale}
hasDraftComment={hasDraftComment}
Expand Down
3 changes: 3 additions & 0 deletions src/components/LHNOptionsList/OptionRowLHNData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ function OptionRowLHNData({
transaction,
lastReportActionTransaction,
transactionViolations,
lastMessageTextFromReport,
...propsToForward
}: OptionRowLHNDataProps) {
const reportID = propsToForward.reportID;
Expand All @@ -49,6 +50,7 @@ function OptionRowLHNData({
policy,
parentReportAction,
hasViolations: !!shouldDisplayViolations || shouldDisplayReportViolations,
lastMessageTextFromReport,
transactionViolations,
invoiceReceiverPolicy,
});
Expand Down Expand Up @@ -76,6 +78,7 @@ function OptionRowLHNData({
receiptTransactions,
invoiceReceiverPolicy,
shouldDisplayReportViolations,
lastMessageTextFromReport,
]);

return (
Expand Down
3 changes: 3 additions & 0 deletions src/components/LHNOptionsList/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ type OptionRowLHNDataProps = {
/** Toggle between compact and default view */
viewMode?: OptionMode;

/** The last message text from the report */
lastMessageTextFromReport: string;

/** A function that is called when an option is selected. Selected option is passed as a param */
onSelectRow?: (optionItem: OptionData, popoverAnchor: RefObject<View>) => void;

Expand Down
8 changes: 7 additions & 1 deletion src/libs/SidebarUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ function getOptionData({
policy,
parentReportAction,
hasViolations,
lastMessageTextFromReport: lastMessageTextFromReportProp,
transactionViolations,
invoiceReceiverPolicy,
}: {
Expand All @@ -250,6 +251,7 @@ function getOptionData({
policy: OnyxEntry<Policy> | undefined;
parentReportAction: OnyxEntry<ReportAction> | undefined;
hasViolations: boolean;
lastMessageTextFromReport?: string;
invoiceReceiverPolicy?: OnyxEntry<Policy>;
transactionViolations?: OnyxCollection<TransactionViolation[]>;
}): ReportUtils.OptionData | undefined {
Expand Down Expand Up @@ -384,7 +386,11 @@ function getOptionData({
}

const lastActorDisplayName = OptionsListUtils.getLastActorDisplayName(lastActorDetails, hasMultipleParticipants);
const lastMessageTextFromReport = OptionsListUtils.getLastMessageTextForReport(report, lastActorDetails, policy);

let lastMessageTextFromReport = lastMessageTextFromReportProp;
if (!lastMessageTextFromReport) {
lastMessageTextFromReport = OptionsListUtils.getLastMessageTextForReport(report, lastActorDetails, policy);
}

// We need to remove sms domain in case the last message text has a phone number mention with sms domain.
let lastMessageText = Str.removeSMSDomain(lastMessageTextFromReport);
Expand Down
Loading