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

remove lastMessageTranslationKey from report collection #54295

2 changes: 0 additions & 2 deletions src/libs/DebugUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,6 @@
case 'reportID':
case 'chatReportID':
case 'type':
case 'lastMessageTranslationKey':
case 'parentReportID':
case 'parentReportActionID':
case 'lastVisibleActionLastModified':
Expand Down Expand Up @@ -600,7 +599,6 @@
writeCapability: CONST.RED_BRICK_ROAD_PENDING_ACTION,
visibility: CONST.RED_BRICK_ROAD_PENDING_ACTION,
invoiceReceiver: CONST.RED_BRICK_ROAD_PENDING_ACTION,
lastMessageTranslationKey: CONST.RED_BRICK_ROAD_PENDING_ACTION,
parentReportID: CONST.RED_BRICK_ROAD_PENDING_ACTION,
parentReportActionID: CONST.RED_BRICK_ROAD_PENDING_ACTION,
managerID: CONST.RED_BRICK_ROAD_PENDING_ACTION,
Expand Down Expand Up @@ -1369,7 +1367,7 @@
}

function getTransactionID(report: OnyxEntry<Report>, reportActions: OnyxEntry<ReportActions>) {
const transactionID = TransactionUtils.getTransactionID(report?.reportID ?? '-1');

Check failure on line 1370 in src/libs/DebugUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check


return Number(transactionID) > 0
? transactionID
Expand Down
6 changes: 2 additions & 4 deletions src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import {FallbackAvatar} from '@components/Icon/Expensicons';
import type {IOUAction} from '@src/CONST';
import CONST from '@src/CONST';
import type {TranslationPaths} from '@src/languages/types';
import ONYXKEYS from '@src/ONYXKEYS';
import type {
Beta,
Expand Down Expand Up @@ -362,7 +361,7 @@
* Get the participant option for a report.
*/
function getParticipantsOption(participant: ReportUtils.OptionData | Participant, personalDetails: OnyxEntry<PersonalDetailsList>): Participant {
const detail = getPersonalDetailsForAccountIDs([participant.accountID ?? -1], personalDetails)[participant.accountID ?? -1];

Check failure on line 364 in src/libs/OptionsListUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Check failure on line 364 in src/libs/OptionsListUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
const login = detail?.login || participant.login || '';
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
Expand All @@ -371,7 +370,7 @@
return {
keyForList: String(detail?.accountID),
login,
accountID: detail?.accountID ?? -1,

Check failure on line 373 in src/libs/OptionsListUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

text: displayName,
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
firstName: (detail?.firstName || ('firstName' in participant ? participant.firstName : '')) ?? '',
Expand Down Expand Up @@ -501,7 +500,7 @@
* Get the last message text from the report directly or from other sources for special cases.
*/
function getLastMessageTextForReport(report: OnyxEntry<Report>, lastActorDetails: Partial<PersonalDetails> | null, policy?: OnyxEntry<Policy>): string {
const reportID = report?.reportID ?? '-1';

Check failure on line 503 in src/libs/OptionsListUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

const lastReportAction = lastVisibleReportActions[reportID] ?? null;

// some types of actions are filtered out for lastReportAction, in some cases we need to check the actual last action
Expand Down Expand Up @@ -535,7 +534,7 @@
lastMessageTextFromReport = ReportUtils.formatReportLastMessageText(properSchemaForMoneyRequestMessage);
} else if (ReportActionUtils.isReportPreviewAction(lastReportAction)) {
const iouReport = ReportUtils.getReportOrDraftReport(ReportActionUtils.getIOUReportIDFromReportActionPreview(lastReportAction));
const lastIOUMoneyReportAction = allSortedReportActions[iouReport?.reportID ?? '-1']?.find(

Check failure on line 537 in src/libs/OptionsListUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

(reportAction, key): reportAction is ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.IOU> =>
ReportActionUtils.shouldReportActionBeVisible(reportAction, key, ReportUtils.canUserPerformWriteAction(report)) &&
reportAction.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE &&
Expand All @@ -557,11 +556,10 @@
lastMessageTextFromReport = ReportUtils.getReimbursementDeQueuedActionMessage(lastReportAction, report, true);
} else if (ReportActionUtils.isDeletedParentAction(lastReportAction) && ReportUtils.isChatReport(report)) {
lastMessageTextFromReport = ReportUtils.getDeletedParentActionMessageForChatReport(lastReportAction);
} else if (ReportActionUtils.isPendingRemove(lastReportAction) && ReportActionUtils.isThreadParentMessage(lastReportAction, report?.reportID ?? '-1')) {

Check failure on line 559 in src/libs/OptionsListUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

lastMessageTextFromReport = Localize.translateLocal('parentReportAction.hiddenMessage');
} else if (ReportUtils.isReportMessageAttachment({text: report?.lastMessageText ?? '-1', html: report?.lastMessageHtml, translationKey: report?.lastMessageTranslationKey, type: ''})) {
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
lastMessageTextFromReport = `[${Localize.translateLocal((report?.lastMessageTranslationKey || 'common.attachment') as TranslationPaths)}]`;
} else if (ReportUtils.isReportMessageAttachment({text: report?.lastMessageText ?? '-1', html: report?.lastMessageHtml, type: ''})) {

Check failure on line 561 in src/libs/OptionsListUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

lastMessageTextFromReport = `[${Localize.translateLocal('common.attachment')}]`;
} else if (ReportActionUtils.isModifiedExpenseAction(lastReportAction)) {
const properSchemaForModifiedExpenseMessage = ModifiedExpenseMessage.getForReportAction(report?.reportID, lastReportAction);
lastMessageTextFromReport = ReportUtils.formatReportLastMessageText(properSchemaForModifiedExpenseMessage, true);
Expand Down Expand Up @@ -700,7 +698,7 @@
hasMultipleParticipants = personalDetailList.length > 1 || result.isChatRoom || result.isPolicyExpenseChat || ReportUtils.isGroupChat(report);
subtitle = ReportUtils.getChatRoomSubtitle(report);

const lastActorDetails = personalDetailMap[report.lastActorAccountID ?? -1] ?? null;

Check failure on line 701 in src/libs/OptionsListUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

const lastActorDisplayName = getLastActorDisplayName(lastActorDetails, hasMultipleParticipants);
const lastMessageTextFromReport = getLastMessageTextForReport(report, lastActorDetails);
let lastMessageText = lastMessageTextFromReport;
Expand Down Expand Up @@ -915,7 +913,7 @@

const allPersonalDetailsOptions = Object.values(personalDetails ?? {}).map((personalDetail) => ({
item: personalDetail,
...createOption([personalDetail?.accountID ?? -1], personalDetails, reportMapForAccountIDs[personalDetail?.accountID ?? -1], {}, {showPersonalDetails: true}),

Check failure on line 916 in src/libs/OptionsListUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

}));

return {
Expand Down
6 changes: 1 addition & 5 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,6 @@ type OptimisticChatReport = Pick<
| 'isOwnPolicyExpenseChat'
| 'isPinned'
| 'lastActorAccountID'
| 'lastMessageTranslationKey'
| 'lastMessageHtml'
| 'lastMessageText'
| 'lastReadTime'
Expand Down Expand Up @@ -5506,7 +5505,6 @@ function buildOptimisticChatReport(
isOwnPolicyExpenseChat,
isPinned: isNewlyCreatedWorkspaceChat,
lastActorAccountID: 0,
lastMessageTranslationKey: '',
lastMessageHtml: '',
lastMessageText: undefined,
lastReadTime: currentTime,
Expand Down Expand Up @@ -6301,7 +6299,7 @@ function isEmptyReport(report: OnyxEntry<Report>): boolean {
return true;
}

if (report.lastMessageText ?? report.lastMessageTranslationKey) {
if (report.lastMessageText) {
return false;
}

Expand Down Expand Up @@ -8421,7 +8419,6 @@ function findPolicyExpenseChatByPolicyID(policyID: string): OnyxEntry<Report> {
*/
function getReportLastMessage(reportID: string, actionsToMerge?: ReportActions) {
let result: Partial<Report> = {
lastMessageTranslationKey: '',
lastMessageText: '',
lastVisibleActionCreated: '',
};
Expand All @@ -8434,7 +8431,6 @@ function getReportLastMessage(reportID: string, actionsToMerge?: ReportActions)
const lastVisibleActionCreated = lastVisibleAction?.created;
const lastActorAccountID = lastVisibleAction?.actorAccountID;
result = {
lastMessageTranslationKey,
lastMessageText,
lastVisibleActionCreated,
lastActorAccountID,
Expand Down
2 changes: 0 additions & 2 deletions src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,6 @@ function buildOnyxDataForMoneyRequest(moneyRequestParams: BuildOnyxDataForMoneyR
value: {
...chat.report,
lastReadTime: DateUtils.getDBTime(),
lastMessageTranslationKey: '',
iouReportID: iou.report.reportID,
...outstandingChildRequest,
...(isNewChatReport ? {pendingFields: {createChat: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD}} : {}),
Expand Down Expand Up @@ -1174,7 +1173,6 @@ function buildOnyxDataForInvoice(
value: {
...chatReport,
lastReadTime: DateUtils.getDBTime(),
lastMessageTranslationKey: '',
iouReportID: iouReport.reportID,
...(isNewChatReport ? {pendingFields: {createChat: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD}} : {}),
},
Expand Down
17 changes: 4 additions & 13 deletions src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,6 @@ function addActions(reportID: string, text = '', file?: FileObject) {

const optimisticReport: Partial<Report> = {
lastVisibleActionCreated: lastAction?.created,
lastMessageTranslationKey: lastComment?.translationKey ?? '',
lastMessageText: lastCommentText,
lastMessageHtml: lastCommentText,
lastActorAccountID: currentUserAccountID,
Expand Down Expand Up @@ -605,7 +604,6 @@ function addActions(reportID: string, text = '', file?: FileObject) {
];

let failureReport: Partial<Report> = {
lastMessageTranslationKey: '',
lastMessageText: '',
lastVisibleActionCreated: '',
};
Expand All @@ -615,7 +613,6 @@ function addActions(reportID: string, text = '', file?: FileObject) {
const lastVisibleActionCreated = lastVisibleAction?.created;
const lastActorAccountID = lastVisibleAction?.actorAccountID;
failureReport = {
lastMessageTranslationKey,
lastMessageText,
lastVisibleActionCreated,
lastActorAccountID,
Expand Down Expand Up @@ -1547,19 +1544,17 @@ function deleteReportComment(reportID: string, reportAction: ReportAction) {
// If we are deleting the last visible message, let's find the previous visible one (or set an empty one if there are none) and update the lastMessageText in the LHN.
// Similarly, if we are deleting the last read comment we will want to update the lastVisibleActionCreated to use the previous visible message.
let optimisticReport: Partial<Report> = {
lastMessageTranslationKey: '',
lastMessageText: '',
lastVisibleActionCreated: '',
};
const {lastMessageText = '', lastMessageTranslationKey = ''} = ReportUtils.getLastVisibleMessage(originalReportID, optimisticReportActions as ReportActions);
const {lastMessageText = ''} = ReportUtils.getLastVisibleMessage(originalReportID, optimisticReportActions as ReportActions);
const report = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`];
const canUserPerformWriteAction = ReportUtils.canUserPerformWriteAction(report);
if (lastMessageText || lastMessageTranslationKey) {
if (lastMessageText) {
const lastVisibleAction = ReportActionsUtils.getLastVisibleAction(originalReportID, canUserPerformWriteAction, optimisticReportActions as ReportActions);
const lastVisibleActionCreated = lastVisibleAction?.created;
const lastActorAccountID = lastVisibleAction?.actorAccountID;
optimisticReport = {
lastMessageTranslationKey,
lastMessageText,
lastVisibleActionCreated,
lastActorAccountID,
Expand Down Expand Up @@ -3854,20 +3849,18 @@ function prepareOnboardingOptimisticData(
}

let failureReport: Partial<Report> = {
lastMessageTranslationKey: '',
lastMessageText: '',
lastVisibleActionCreated: '',
hasOutstandingChildTask: false,
};
const report = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${targetChatReportID}`];
const canUserPerformWriteAction = ReportUtils.canUserPerformWriteAction(report);
const {lastMessageText = '', lastMessageTranslationKey = ''} = ReportActionsUtils.getLastVisibleMessage(targetChatReportID, canUserPerformWriteAction);
if (lastMessageText || lastMessageTranslationKey) {
const {lastMessageText = ''} = ReportActionsUtils.getLastVisibleMessage(targetChatReportID, canUserPerformWriteAction);
if (lastMessageText) {
const lastVisibleAction = ReportActionsUtils.getLastVisibleAction(targetChatReportID, canUserPerformWriteAction);
const prevLastVisibleActionCreated = lastVisibleAction?.created;
const lastActorAccountID = lastVisibleAction?.actorAccountID;
failureReport = {
lastMessageTranslationKey,
lastMessageText,
lastVisibleActionCreated: prevLastVisibleActionCreated,
lastActorAccountID,
Expand Down Expand Up @@ -4169,7 +4162,6 @@ function resolveActionableMentionWhisper(reportId: string, reportAction: OnyxEnt
const reportUpdateDataWithPreviousLastMessage = ReportUtils.getReportLastMessage(reportId, optimisticReportActions as ReportActions);

const reportUpdateDataWithCurrentLastMessage = {
lastMessageTranslationKey: report?.lastMessageTranslationKey,
lastMessageText: report?.lastMessageText,
lastVisibleActionCreated: report?.lastVisibleActionCreated,
lastActorAccountID: report?.lastActorAccountID,
Expand Down Expand Up @@ -4244,7 +4236,6 @@ function resolveActionableReportMentionWhisper(
const reportUpdateDataWithPreviousLastMessage = ReportUtils.getReportLastMessage(reportId, optimisticReportActions as ReportActions);

const reportUpdateDataWithCurrentLastMessage = {
lastMessageTranslationKey: report?.lastMessageTranslationKey,
lastMessageText: report?.lastMessageText,
lastVisibleActionCreated: report?.lastVisibleActionCreated,
lastActorAccountID: report?.lastActorAccountID,
Expand Down
3 changes: 0 additions & 3 deletions src/types/onyx/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,6 @@ type Report = OnyxCommon.OnyxValueWithOfflineFeedback<
/** Invoice room receiver data */
invoiceReceiver?: InvoiceReceiver;

/** Translation key of the last message in the report */
lastMessageTranslationKey?: string;

/** ID of the parent report of the current report, if it exists */
parentReportID?: string;

Expand Down
1 change: 0 additions & 1 deletion src/types/utils/whitelistedReportKeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ type WhitelistedReport = OnyxCommon.OnyxValueWithOfflineFeedback<
type: unknown;
visibility: unknown;
invoiceReceiver: unknown;
lastMessageTranslationKey: unknown;
parentReportID: unknown;
parentReportActionID: unknown;
managerID: unknown;
Expand Down
Loading