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

Add violations to Search actions #54847

Merged
merged 12 commits into from
Jan 14, 2025
Prev Previous commit
Next Next commit
fix types
  • Loading branch information
luacmartins committed Jan 6, 2025
commit 2d549dce74116ff98769a3dcbb4c63db919a2385
9 changes: 3 additions & 6 deletions src/libs/SearchUIUtils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type {OnyxCollection} from 'react-native-onyx';
import type {ValueOf} from 'type-fest';
import type {SearchColumnType, SearchStatus, SortOrder} from '@components/Search/types';
import ChatListItem from '@components/SelectionList/ChatListItem';
@@ -20,7 +21,6 @@ import Navigation from './Navigation/Navigation';
import * as ReportActionsUtils from './ReportActionsUtils';
import * as ReportUtils from './ReportUtils';
import * as TransactionUtils from './TransactionUtils';
import { OnyxCollection } from 'react-native-onyx';

const columnNamesToSortingProperty = {
[CONST.SEARCH.TABLE_COLUMNS.TO]: 'formattedTo' as const,
@@ -308,12 +308,9 @@ function getAction(data: OnyxTypes.SearchResults['data'], key: string): SearchTr

const chatReport = data[`${ONYXKEYS.COLLECTION.REPORT}${report?.chatReportID}`] ?? {};
const chatReportRNVP = data[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.chatReportID}`] ?? undefined;
const allViolations = Object.entries(data)
.filter(([itemKey]) => isViolationEntry(itemKey))
.map((item) => ({[item[0]]: item[1]}));
console.log('over here', allViolations);
const allViolations = Object.fromEntries(Object.entries(data).filter(([itemKey]) => isViolationEntry(itemKey))) as OnyxCollection<OnyxTypes.TransactionViolation[]>;

if (ReportUtils.hasViolations(report.reportID, allViolations, true, allReportTransactions)) {
if (ReportUtils.hasViolations(report.reportID, allViolations, undefined, allReportTransactions)) {
return CONST.SEARCH.ACTION_TYPES.REVIEW;
}

2 changes: 1 addition & 1 deletion src/types/onyx/SearchResults.ts
Original file line number Diff line number Diff line change
@@ -393,7 +393,7 @@ type SearchResults = {
PrefixedRecord<typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS, Record<string, SearchReportAction>> &
PrefixedRecord<typeof ONYXKEYS.COLLECTION.REPORT, SearchReport> &
PrefixedRecord<typeof ONYXKEYS.COLLECTION.POLICY, SearchPolicy> &
PrefixedRecord<typeof ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS, TransactionViolation> &
PrefixedRecord<typeof ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS, TransactionViolation[]> &
PrefixedRecord<typeof ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS, ReportNameValuePairs>;

/** Whether search data is being fetched from server */