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

[CP Staging] Fix thread title not updated in header and in LHN after editing parent message #44526

Merged
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
4 changes: 2 additions & 2 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3318,9 +3318,9 @@ function getInvoicesChatName(report: OnyxEntry<Report>): string {
/**
* Get the title for a report.
*/
function getReportName(report: OnyxEntry<Report>, policy?: OnyxEntry<Policy>): string {
function getReportName(report: OnyxEntry<Report>, policy?: OnyxEntry<Policy>, parentReportActionParam?: OnyxInputOrEntry<ReportAction>): string {
let formattedName: string | undefined;
const parentReportAction = ReportActionsUtils.getParentReportAction(report);
const parentReportAction = parentReportActionParam ?? ReportActionsUtils.getParentReportAction(report);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are quite a few uses of getReportName and to not affect the others, I add the param and fallback to getParentReportAction.

if (isChatThread(report)) {
if (!isEmptyObject(parentReportAction) && ReportActionsUtils.isTransactionThread(parentReportAction)) {
formattedName = getTransactionReportName(parentReportAction);
Expand Down
1 change: 1 addition & 0 deletions src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1538,6 +1538,7 @@ function editReportComment(reportID: string, originalReportAction: OnyxEntry<Rep
text: reportComment,
},
],
lastModified: DateUtils.getDBTime(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't we need to revert this in the failure data?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I realized that the failureData already has the previous report action, so I think no need to add lastModified: originalReportAction.lastModified, again.

App/src/libs/actions/Report.ts

Lines 1566 to 1574 in 9d8e7fe

const failureData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${originalReportID}`,
value: {
[reportActionID]: {
...originalReportAction,
pendingAction: null,
},

Copy link
Contributor

Choose a reason for hiding this comment

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

Ohhhh ok yeah, that makes sense

},
};

Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/HeaderView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function HeaderView({
const isTaskReport = ReportUtils.isTaskReport(report);
const reportHeaderData = !isTaskReport && !isChatThread && report.parentReportID ? parentReport : report;
// Use sorted display names for the title for group chats on native small screen widths
const title = ReportUtils.getReportName(reportHeaderData);
const title = ReportUtils.getReportName(reportHeaderData, undefined, parentReportAction);
const subtitle = ReportUtils.getChatRoomSubtitle(reportHeaderData);
const parentNavigationSubtitleData = ReportUtils.getParentNavigationSubtitle(reportHeaderData);
const isConcierge = ReportUtils.isConciergeChatReport(report);
Expand Down
Loading