Skip to content

[CP Staging] Fix workspace chat showing up #61969

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

Merged
merged 2 commits into from
May 14, 2025
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
2 changes: 1 addition & 1 deletion src/libs/SearchUIUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ function getReportSections(data: OnyxTypes.SearchResults['data'], metadata: Onyx

const reportIDToTransactions: Record<string, ReportListItemType> = {};
for (const key in data) {
if (isReportEntry(key)) {
if (isReportEntry(key) && (data[key].type === CONST.REPORT.TYPE.IOU || data[key].type === CONST.REPORT.TYPE.EXPENSE || data[key].type === CONST.REPORT.TYPE.INVOICE)) {
Copy link
Member

Choose a reason for hiding this comment

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

if you wanna be nice and tidy, you could declare at the top of file:

const moneyRequestReportTypes = [....]

then

Suggested change
if (isReportEntry(key) && (data[key].type === CONST.REPORT.TYPE.IOU || data[key].type === CONST.REPORT.TYPE.EXPENSE || data[key].type === CONST.REPORT.TYPE.INVOICE)) {
(...) && moneyRequestReportTypes.includes(data[key].type))

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 agreement with this suggestion

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestion. I'm trying to implement it but it creates a nasty TS error that I can't seem to get rid off, no matter what I do haha
Screenshot 2025-05-14 at 8 52 52 AM

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It complains about the argument being undefined, but when I explicitly check for that it still results in a type error 🤔

const reportItem = {...data[key]};
const reportKey = `${ONYXKEYS.COLLECTION.REPORT}${reportItem.reportID}`;
const transactions = reportIDToTransactions[reportKey]?.transactions ?? [];
Expand Down
9 changes: 9 additions & 0 deletions tests/unit/Search/SearchUIUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const policyID = 'A1B2C3';
const reportID = '123456789';
const reportID2 = '11111';
const reportID3 = '99999';
const reportID4 = '6155022250251839';
const transactionID = '1';
const transactionID2 = '2';
const transactionID3 = '3';
Expand Down Expand Up @@ -197,6 +198,14 @@ const searchResults: OnyxTypes.SearchResults = {
type: 'iou',
unheldTotal: 4400,
},
[`report_${reportID4}`]: {
accountID: adminAccountID,
reportID: reportID4,
chatReportID: '',
chatType: 'policyExpenseChat',
created: '2025-03-05 16:34:27',
type: 'chat',
},
[`transactions_${transactionID}`]: {
accountID: adminAccountID,
action: 'view',
Expand Down
Loading