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

Make getAllReports not include undefined #52634

Closed
wants to merge 1 commit into from
Closed
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
5 changes: 2 additions & 3 deletions src/libs/ReportConnection.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type {OnyxCollection} from 'react-native-onyx';
import Onyx from 'react-native-onyx';
import ONYXKEYS from '@src/ONYXKEYS';
import type {Report} from '@src/types/onyx';
Expand All @@ -9,12 +8,12 @@
const UnreadIndicatorUpdaterHelper = () => import('./UnreadIndicatorUpdater');

const reportIDToNameMap: Record<string, string> = {};
let allReports: OnyxCollection<Report>;
let allReports: Record<string, Report>;
Onyx.connect({
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
callback: (value) => {
allReports = value;
allReports = Object.fromEntries(Object.entries(value).filter(([, report]) => !!report));

Check failure on line 16 in src/libs/ReportConnection.ts

View workflow job for this annotation

GitHub Actions / typecheck

Type '{ [k: string]: ({ avatarUrl?: string | undefined; avatarFileName?: string | undefined; chatType?: ValueOf<{ readonly POLICY_ANNOUNCE: "policyAnnounce"; readonly POLICY_ADMINS: "policyAdmins"; ... 7 more ...; readonly SYSTEM: "system"; }> | undefined; ... 58 more ...; private_isArchived?: string | undefined; } & Offl...' is not assignable to type 'Record<string, { avatarUrl?: string | undefined; avatarFileName?: string | undefined; chatType?: ValueOf<{ readonly POLICY_ANNOUNCE: "policyAnnounce"; readonly POLICY_ADMINS: "policyAdmins"; ... 7 more ...; readonly SYSTEM: "system"; }> | undefined; ... 58 more ...; private_isArchived?: string | undefined; } & Offli...'.
UnreadIndicatorUpdaterHelper().then((module) => {
module.triggerUnreadUpdate();
});
Expand Down
4 changes: 2 additions & 2 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1402,7 +1402,7 @@
let reportsValues = Object.values(allReports ?? {});

if (!!policyID || policyMemberAccountIDs.length > 0) {
reportsValues = filterReportsByPolicyIDAndMemberAccountIDs(reportsValues, policyMemberAccountIDs, policyID);

Check failure on line 1405 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / typecheck

Type 'OnyxEntry<{ avatarUrl?: string | undefined; avatarFileName?: string | undefined; chatType?: ValueOf<{ readonly POLICY_ANNOUNCE: "policyAnnounce"; readonly POLICY_ADMINS: "policyAdmins"; readonly TRIP_ROOM: "tripRoom"; ... 6 more ...; readonly SYSTEM: "system"; }> | undefined; ... 58 more ...; private_isArchived?: st...' is not assignable to type '({ avatarUrl?: string | undefined; avatarFileName?: string | undefined; chatType?: ValueOf<{ readonly POLICY_ANNOUNCE: "policyAnnounce"; readonly POLICY_ADMINS: "policyAdmins"; readonly TRIP_ROOM: "tripRoom"; ... 6 more ...; readonly SYSTEM: "system"; }> | undefined; ... 58 more ...; private_isArchived?: string | un...'.
}

let adminReport: OnyxEntry<Report>;
Expand Down Expand Up @@ -6350,8 +6350,8 @@
// - Are either open or submitted
// - Belong to the same workspace
// And if any have a violation, then it should have a RBR
const allReports = Object.values(ReportConnection.getAllReports() ?? {}) as Report[];
const potentialReports = allReports.filter((r) => r?.ownerAccountID === currentUserAccountID && (r?.stateNum ?? 0) <= 1 && r?.policyID === report.policyID);
const allReports = Object.values(ReportConnection.getAllReports() ?? {});
const potentialReports = allReports.filter((r) => r.ownerAccountID === currentUserAccountID && (r.stateNum ?? 0) <= 1 && r.policyID === report.policyID);
return potentialReports.some(
(potentialReport) => hasViolations(potentialReport.reportID, transactionViolations) || hasWarningTypeViolations(potentialReport.reportID, transactionViolations),
);
Expand Down
Loading