Skip to content

Commit 2fa04d3

Browse files
authored
Merge pull request Expensify#64542 from Expensify/revert-62245-chat-thread-skeleton-new
2 parents e0250b5 + 97506c8 commit 2fa04d3

4 files changed

Lines changed: 4 additions & 201 deletions

File tree

src/libs/ReportActionsUtils.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ function getReportActionMessage(reportAction: PartialReportAction) {
183183
}
184184

185185
function isDeletedParentAction(reportAction: OnyxInputOrEntry<ReportAction>): boolean {
186-
return isMessageDeleted(reportAction) && (reportAction?.childVisibleActionCount ?? 0) > 0;
186+
return (getReportActionMessage(reportAction)?.isDeletedParentAction ?? false) && (reportAction?.childVisibleActionCount ?? 0) > 0;
187187
}
188188

189189
function isReversedTransaction(reportAction: OnyxInputOrEntry<ReportAction | OptimisticIOUReportAction>) {
@@ -1110,15 +1110,7 @@ function getIOUReportIDFromReportActionPreview(reportAction: OnyxEntry<ReportAct
11101110
* A helper method to identify if the message is deleted or not.
11111111
*/
11121112
function isMessageDeleted(reportAction: OnyxInputOrEntry<ReportAction>): boolean {
1113-
const message = getReportActionMessage(reportAction);
1114-
const originalMessage = getOriginalMessage(reportAction) as Message;
1115-
1116-
return (
1117-
(message?.isDeletedParentAction ?? false) ||
1118-
(message?.deleted !== undefined && message?.deleted !== '') ||
1119-
(originalMessage?.isDeletedParentAction ?? false) ||
1120-
(originalMessage?.deleted !== undefined && originalMessage?.deleted !== '')
1121-
);
1113+
return getReportActionMessage(reportAction)?.isDeletedParentAction ?? false;
11221114
}
11231115

11241116
/**
@@ -1811,9 +1803,6 @@ function getReportActionMessageFragments(action: ReportAction): Message[] {
18111803

18121804
const actionMessage = action.previousMessage ?? action.message;
18131805
if (Array.isArray(actionMessage)) {
1814-
if (actionMessage?.length === 1) {
1815-
return [{...actionMessage.at(0), isDeletedParentAction: isMessageDeleted(action)} as Message];
1816-
}
18171806
return actionMessage.filter((item): item is Message => !!item);
18181807
}
18191808
return actionMessage ? [actionMessage] : [];

src/libs/ReportUtils.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@ import {
183183
isExportIntegrationAction,
184184
isIntegrationMessageAction,
185185
isMarkAsClosedAction,
186-
isMessageDeleted,
187186
isModifiedExpenseAction,
188187
isMoneyRequestAction,
189188
isOldDotReportAction,
@@ -4985,7 +4984,6 @@ function getReportName(
49854984
const canUseDerivedValue = report && policy === undefined && parentReportActionParam === undefined && personalDetails === undefined && invoiceReceiverPolicy === undefined;
49864985
const attributes = reportAttributes ?? reportAttributesDerivedValue;
49874986
const derivedNameExists = report && !!attributes?.[report.reportID]?.reportName;
4988-
// This doesn't apply to chat reports because last message (report name) can be changed and/or edited
49894987
if (canUseDerivedValue && derivedNameExists) {
49904988
return attributes[report.reportID].reportName;
49914989
}
@@ -5000,19 +4998,6 @@ function getSearchReportName(props: GetReportNameParams): string {
50004998
return getReportNameInternal(props);
50014999
}
50025000

5003-
function isChatThreadDeleted(report: OnyxInputOrEntry<Report>, reportActionParam: OnyxInputOrEntry<ReportAction>): boolean {
5004-
if (!isChatThread(report)) {
5005-
return false;
5006-
}
5007-
5008-
let reportAction = reportActionParam as OnyxEntry<ReportAction>;
5009-
if (!reportAction) {
5010-
reportAction = getReportAction(report?.parentReportID, report?.parentReportActionID);
5011-
}
5012-
5013-
return isMessageDeleted(reportAction);
5014-
}
5015-
50165001
function getInvoiceReportName(report: OnyxEntry<Report>, policy?: OnyxEntry<Policy | SearchPolicy>, invoiceReceiverPolicy?: OnyxEntry<Policy | SearchPolicy>): string {
50175002
const moneyRequestReportName = getMoneyRequestReportName({report, policy, invoiceReceiverPolicy});
50185003
const oldDotInvoiceName = report?.reportName ?? moneyRequestReportName;
@@ -5186,7 +5171,7 @@ function getReportNameInternal({
51865171
return getRenamedAction(parentReportAction, isExpenseReport(getReport(report.parentReportID, allReports)));
51875172
}
51885173

5189-
if (isChatThreadDeleted(report, parentReportActionParam)) {
5174+
if (parentReportActionMessage?.isDeletedParentAction) {
51905175
return translateLocal('parentReportAction.deletedMessage');
51915176
}
51925177

@@ -11267,7 +11252,6 @@ export {
1126711252
isChatRoom,
1126811253
isTripRoom,
1126911254
isChatThread,
11270-
isChatThreadDeleted,
1127111255
isChildReport,
1127211256
isClosedExpenseReportWithNoExpenses,
1127311257
isCompletedTaskReport,

tests/unit/ReportActionsUtilsTest.ts

Lines changed: 1 addition & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,7 @@ import {actionR14932 as mockIOUAction, originalMessageR14932 as mockOriginalMess
66
import {chatReportR14932 as mockChatReport, iouReportR14932 as mockIOUReport} from '../../__mocks__/reportData/reports';
77
import CONST from '../../src/CONST';
88
import * as ReportActionsUtils from '../../src/libs/ReportActionsUtils';
9-
import {
10-
getOneTransactionThreadReportID,
11-
getOriginalMessage,
12-
getSendMoneyFlowOneTransactionThreadID,
13-
isIOUActionMatchingTransactionList,
14-
isMessageDeleted,
15-
} from '../../src/libs/ReportActionsUtils';
9+
import {getOneTransactionThreadReportID, getOriginalMessage, getSendMoneyFlowOneTransactionThreadID, isIOUActionMatchingTransactionList} from '../../src/libs/ReportActionsUtils';
1610
import ONYXKEYS from '../../src/ONYXKEYS';
1711
import type {Report, ReportAction} from '../../src/types/onyx';
1812
import createRandomReport from '../utils/collections/reports';
@@ -821,108 +815,6 @@ describe('ReportActionsUtils', () => {
821815
});
822816
});
823817

824-
describe('isMessageDeleted', () => {
825-
it('should return true if there is property deleted inside message', () => {
826-
const reportAction = {
827-
created: '2025-05-12 17:27:01.825',
828-
reportActionID: '8401445780099176',
829-
actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT,
830-
originalMessage: {
831-
html: 'Hello world',
832-
whisperedTo: [],
833-
},
834-
message: [
835-
{
836-
html: 'Hello world',
837-
deleted: '2025-05-12 17:37:01.825',
838-
type: CONST.REPORT.MESSAGE.TYPE.COMMENT,
839-
text: '',
840-
},
841-
],
842-
};
843-
expect(isMessageDeleted(reportAction)).toBeTruthy();
844-
});
845-
it('should return true if there is property isDeletedParentAction inside message', () => {
846-
const reportAction = {
847-
created: '2025-05-12 17:27:01.825',
848-
reportActionID: '8401445780099176',
849-
actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT,
850-
originalMessage: {
851-
html: 'Hello world',
852-
whisperedTo: [],
853-
},
854-
message: [
855-
{
856-
html: 'Hello world',
857-
isDeletedParentAction: true,
858-
type: CONST.REPORT.MESSAGE.TYPE.COMMENT,
859-
text: '',
860-
},
861-
],
862-
};
863-
expect(isMessageDeleted(reportAction)).toBeTruthy();
864-
});
865-
it('should return true if there is property deleted inside original message', () => {
866-
const reportAction = {
867-
created: '2025-05-12 17:27:01.825',
868-
reportActionID: '8401445780099176',
869-
actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT,
870-
originalMessage: {
871-
html: 'Hello world',
872-
whisperedTo: [],
873-
deleted: '2025-05-12 17:37:01.825',
874-
},
875-
message: [
876-
{
877-
html: 'Hello world',
878-
type: CONST.REPORT.MESSAGE.TYPE.COMMENT,
879-
text: '',
880-
},
881-
],
882-
};
883-
expect(isMessageDeleted(reportAction)).toBeTruthy();
884-
});
885-
it('should return true if there is property isDeletedParentAction inside original message', () => {
886-
const reportAction = {
887-
created: '2025-05-12 17:27:01.825',
888-
reportActionID: '8401445780099176',
889-
actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT,
890-
originalMessage: {
891-
html: 'Hello world',
892-
whisperedTo: [],
893-
isDeletedParentAction: true,
894-
},
895-
message: [
896-
{
897-
html: 'Hello world',
898-
type: CONST.REPORT.MESSAGE.TYPE.COMMENT,
899-
text: '',
900-
},
901-
],
902-
};
903-
expect(isMessageDeleted(reportAction)).toBeTruthy();
904-
});
905-
it('should return false if there are no deletion properties in message and originalMessage', () => {
906-
const reportAction = {
907-
created: '2025-05-12 17:27:01.825',
908-
reportActionID: '8401445780099176',
909-
actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT,
910-
originalMessage: {
911-
html: 'Hello world',
912-
whisperedTo: [],
913-
},
914-
message: [
915-
{
916-
html: 'Hello world',
917-
type: CONST.REPORT.MESSAGE.TYPE.COMMENT,
918-
text: '',
919-
},
920-
],
921-
};
922-
expect(isMessageDeleted(reportAction)).toBeFalsy();
923-
});
924-
});
925-
926818
describe('getReportActionMessageFragments', () => {
927819
it('should return the correct fragment for the REIMBURSED action', () => {
928820
const action = {
@@ -961,22 +853,6 @@ describe('ReportActionsUtils', () => {
961853
const expectedFragments = ReportActionsUtils.getReportActionMessageFragments(action);
962854
expect(expectedFragments).toEqual([{text: expectedMessage, html: `<muted-text>${expectedMessage}</muted-text>`, type: 'COMMENT'}]);
963855
});
964-
it('should return the correct fragment for the deleted message', () => {
965-
const action = {
966-
actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT,
967-
reportActionID: '1',
968-
created: '1',
969-
message: [
970-
{
971-
type: CONST.REPORT.MESSAGE.TYPE.COMMENT,
972-
text: '',
973-
deleted: '2025-05-12 17:27:01.825',
974-
},
975-
],
976-
};
977-
const expectedFragments = ReportActionsUtils.getReportActionMessageFragments(action);
978-
expect(expectedFragments).toEqual([{text: '', type: CONST.REPORT.MESSAGE.TYPE.COMMENT, isDeletedParentAction: true, deleted: '2025-05-12 17:27:01.825'}]);
979-
});
980856
});
981857

982858
describe('getSendMoneyFlowOneTransactionThreadID', () => {

tests/unit/ReportUtilsTest.ts

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -459,52 +459,6 @@ describe('ReportUtils', () => {
459459
).toBe('floki@vikings.net');
460460
});
461461

462-
test('with deleted message and provided parent action param', () => {
463-
const report = {
464-
type: CONST.REPORT.TYPE.CHAT,
465-
reportID: '4401445780099175',
466-
parentReportActionID: '8401445780099176',
467-
parentReportID: '4401445780099175',
468-
};
469-
const reportAction = {
470-
created: '2025-05-12 17:27:01.825',
471-
reportActionID: '8401445780099176',
472-
actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT,
473-
message: [
474-
{
475-
deleted: '2025-05-12 17:27:01.825',
476-
type: CONST.REPORT.MESSAGE.TYPE.COMMENT,
477-
text: '',
478-
},
479-
],
480-
};
481-
expect(getReportName(report, undefined, reportAction)).toEqual(translateLocal('parentReportAction.deletedMessage'));
482-
});
483-
484-
test('with deleted message and not provided parent action param', async () => {
485-
const report = {
486-
type: CONST.REPORT.TYPE.CHAT,
487-
parentReportActionID: '8401445780099176',
488-
parentReportID: '4401445780099175',
489-
reportID: '2401445780099174',
490-
};
491-
const reportAction = {
492-
reportActionID: '8401445780099176',
493-
parentReportID: '',
494-
message: [
495-
{
496-
deleted: '2025-05-12 17:27:01.825',
497-
type: CONST.REPORT.MESSAGE.TYPE.COMMENT,
498-
text: '',
499-
},
500-
],
501-
};
502-
await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.parentReportID}`, {
503-
[reportAction.reportActionID]: reportAction,
504-
});
505-
expect(getReportName(report)).toEqual(translateLocal('parentReportAction.deletedMessage'));
506-
});
507-
508462
test('SMS', () => {
509463
expect(
510464
getReportName({

0 commit comments

Comments
 (0)