Skip to content

Commit

Permalink
Merge pull request Expensify#52395 from callstack-internal/chore/remo…
Browse files Browse the repository at this point in the history
…ve-displayName-and-errors-from-reports

[No QA] chore: remove displayName and errors from Report type
  • Loading branch information
puneetlath authored Nov 18, 2024
2 parents 0cf3405 + a8ee09f commit 941e795
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const getMentionDetails = (htmlAttributeReportID: string, currentReport: OnyxEnt
if (!isEmpty(htmlAttributeReportID)) {
const report = reports?.[`${ONYXKEYS.COLLECTION.REPORT}${htmlAttributeReportID}`];
reportID = report?.reportID ?? htmlAttributeReportID;
mentionDisplayText = removeLeadingLTRAndHash(report?.reportName ?? report?.displayName ?? htmlAttributeReportID);
mentionDisplayText = removeLeadingLTRAndHash(report?.reportName ?? htmlAttributeReportID);
// Get mention details from name inside tnode
} else if ('data' in tnode && !isEmptyObject(tnode.data)) {
mentionDisplayText = removeLeadingLTRAndHash(tnode.data);
Expand Down
2 changes: 1 addition & 1 deletion src/libs/ReportConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Onyx.connect({
if (!report) {
return;
}
reportIDToNameMap[report.reportID] = report.reportName ?? report.displayName ?? report.reportID;
reportIDToNameMap[report.reportID] = report.reportName ?? report.reportID;
ReportHelperActions.handleReportChanged(report);
});
},
Expand Down
3 changes: 1 addition & 2 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,7 @@ type OptionData = {
participantsList?: PersonalDetails[];
icons?: Icon[];
iouReportAmount?: number;
displayName?: string;
} & Report;

type OnyxDataTaskAssigneeChat = {
Expand Down Expand Up @@ -6453,13 +6454,11 @@ function getAllReportActionsErrorsAndReportActionThatRequiresAttention(report: O
* Get an object of error messages keyed by microtime by combining all error objects related to the report.
*/
function getAllReportErrors(report: OnyxEntry<Report>, reportActions: OnyxEntry<ReportActions>): Errors {
const reportErrors = report?.errors ?? {};
const reportErrorFields = report?.errorFields ?? {};
const {errors: reportActionErrors} = getAllReportActionsErrorsAndReportActionThatRequiresAttention(report, reportActions);

// All error objects related to the report. Each object in the sources contains error messages keyed by microtime
const errorSources = {
reportErrors,
...reportErrorFields,
...reportActionErrors,
};
Expand Down
6 changes: 0 additions & 6 deletions src/types/onyx/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,6 @@ type Report = OnyxCommon.OnyxValueWithOfflineFeedback<
/** When was the last visible action last modified */
lastVisibleActionLastModified?: string;

/** Display name of the report, shown in options and mentions */
displayName?: string;

/** HTML content of the last message in the report */
lastMessageHtml?: string;

Expand All @@ -205,9 +202,6 @@ type Report = OnyxCommon.OnyxValueWithOfflineFeedback<
/** For expense reports, this is the currency of the expense */
currency?: string;

/** Collection of errors to be shown to the user */
errors?: OnyxCommon.Errors;

/** Collection of errors that exist in report fields */
errorFields?: OnyxCommon.ErrorFields;

Expand Down
2 changes: 0 additions & 2 deletions src/types/utils/whitelistedReportKeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ type WhitelistedReport = OnyxCommon.OnyxValueWithOfflineFeedback<
isOptimisticReport: unknown;
managerID: unknown;
lastVisibleActionLastModified: unknown;
displayName: unknown;
lastMessageHtml: unknown;
lastActorAccountID: unknown;
lastActionType: unknown;
Expand All @@ -52,7 +51,6 @@ type WhitelistedReport = OnyxCommon.OnyxValueWithOfflineFeedback<
total: unknown;
unheldTotal: unknown;
currency: unknown;
errors: unknown;
errorFields: unknown;
isWaitingOnBankAccount: unknown;
isCancelledIOU: unknown;
Expand Down
10 changes: 1 addition & 9 deletions tests/unit/DebugUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -860,15 +860,7 @@ describe('DebugUtils', () => {
expect(reason).toBe('debug.reasonVisibleInLHN.hasRBR');
});
it('returns correct reason when report has errors', () => {
const reason = DebugUtils.getReasonForShowingRowInLHN(
{
...baseReport,
errors: {
error: 'Something went wrong',
},
},
true,
);
const reason = DebugUtils.getReasonForShowingRowInLHN(baseReport, true);
expect(reason).toBe('debug.reasonVisibleInLHN.hasRBR');
});
});
Expand Down
1 change: 0 additions & 1 deletion tests/utils/collections/reports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export default function createRandomReport(index: number): Report {
reportID: index.toString(),
chatType: rand(Object.values(CONST.REPORT.CHAT_TYPE)),
currency: randCurrencyCode(),
displayName: randWord(),
ownerAccountID: index,
isPinned: randBoolean(),
isOptimisticReport: randBoolean(),
Expand Down

0 comments on commit 941e795

Please sign in to comment.