Skip to content
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
8 changes: 7 additions & 1 deletion src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,9 @@ const ONYXKEYS = {
NVP_LAST_ECASH_ANDROID_LOGIN: 'nvp_lastECashAndroidLogin',
NVP_LAST_ANDROID_LOGIN: 'nvp_lastAndroidLogin',

/** Draft report comments */
NVP_DRAFT_REPORT_COMMENTS: 'nvp_draftReportComments',

/** Collection Keys */
COLLECTION: {
DOWNLOAD: 'download_',
Expand Down Expand Up @@ -586,7 +589,8 @@ const ONYXKEYS = {
REPORT_ACTIONS_DRAFTS: 'reportActionsDrafts_',
REPORT_ACTIONS_PAGES: 'reportActionsPages_',
REPORT_ACTIONS_REACTIONS: 'reportActionsReactions_',
REPORT_DRAFT_COMMENT: 'reportDraftComment_',
/** @deprecated */
REPORT_DRAFT_COMMENT: 'reportDraftComment_', // eslint-disable-line deprecation/deprecation
REPORT_IS_COMPOSER_FULL_SIZE: 'reportIsComposerFullSize_',
REPORT_USER_IS_TYPING: 'reportUserIsTyping_',
REPORT_USER_IS_LEAVING_ROOM: 'reportUserIsLeavingRoom_',
Expand Down Expand Up @@ -984,6 +988,7 @@ type OnyxCollectionValuesMapping = {
[ONYXKEYS.COLLECTION.REPORT_ACTIONS_DRAFTS]: OnyxTypes.ReportActionsDrafts;
[ONYXKEYS.COLLECTION.REPORT_ACTIONS_PAGES]: OnyxTypes.Pages;
[ONYXKEYS.COLLECTION.REPORT_ACTIONS_REACTIONS]: OnyxTypes.ReportActionReactions;
// eslint-disable-next-line deprecation/deprecation
[ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT]: string;
[ONYXKEYS.COLLECTION.REPORT_IS_COMPOSER_FULL_SIZE]: boolean;
[ONYXKEYS.COLLECTION.REPORT_USER_IS_TYPING]: OnyxTypes.ReportUserIsTyping;
Expand Down Expand Up @@ -1204,6 +1209,7 @@ type OnyxValuesMapping = {
[ONYXKEYS.TRANSACTION_THREAD_NAVIGATION_REPORT_IDS]: string[];
[ONYXKEYS.ONBOARDING_USER_REPORTED_INTEGRATION]: OnboardingAccounting;
[ONYXKEYS.HYBRID_APP]: OnyxTypes.HybridApp;
[ONYXKEYS.NVP_DRAFT_REPORT_COMMENTS]: OnyxTypes.DraftReportComments;
Comment thread
chuckdries marked this conversation as resolved.
};

type OnyxDerivedValuesMapping = {
Expand Down
7 changes: 2 additions & 5 deletions src/components/LHNOptionsList/LHNOptionsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import useRootNavigationState from '@hooks/useRootNavigationState';
import useScrollEventEmitter from '@hooks/useScrollEventEmitter';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import {isValidDraftComment} from '@libs/DraftCommentUtils';
import getPlatform from '@libs/getPlatform';
import Log from '@libs/Log';
import {getIOUReportIDOfLastAction, getLastMessageTextForReport} from '@libs/OptionsListUtils';
Expand Down Expand Up @@ -53,7 +52,7 @@ function LHNOptionsList({style, contentContainerStyles, data, onSelectRow, optio
const [policy] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {canBeMissing: false});
const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {canBeMissing: true});
const [transactions] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION, {canBeMissing: false});
const [draftComments] = useOnyx(ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT, {canBeMissing: false});
const [draftComments] = useOnyx(ONYXKEYS.NVP_DRAFT_REPORT_COMMENTS, {canBeMissing: true});
const [transactionViolations] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS, {canBeMissing: false});
const [dismissedProductTraining, dismissedProductTrainingMetadata] = useOnyx(ONYXKEYS.NVP_DISMISSED_PRODUCT_TRAINING, {canBeMissing: true});
const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID, {canBeMissing: true});
Expand Down Expand Up @@ -189,7 +188,7 @@ function LHNOptionsList({style, contentContainerStyles, data, onSelectRow, optio
? (getOriginalMessage(itemParentReportAction)?.IOUTransactionID ?? CONST.DEFAULT_NUMBER_ID)
: CONST.DEFAULT_NUMBER_ID;
const itemTransaction = transactions?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`];
const hasDraftComment = isValidDraftComment(draftComments?.[`${ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT}${reportID}`]);
const hasDraftComment = !!draftComments?.[reportID];

const canUserPerformWrite = canUserPerformWriteAction(item);
const sortedReportActions = getSortedReportActionsForDisplay(itemReportActions, canUserPerformWrite);
Expand Down Expand Up @@ -284,7 +283,6 @@ function LHNOptionsList({style, contentContainerStyles, data, onSelectRow, optio
policy,
personalDetails,
data.length,
draftComments,
optionMode,
preferredLocale,
transactions,
Expand All @@ -301,7 +299,6 @@ function LHNOptionsList({style, contentContainerStyles, data, onSelectRow, optio
policy,
personalDetails,
data.length,
draftComments,
optionMode,
preferredLocale,
transactions,
Expand Down
16 changes: 16 additions & 0 deletions src/hooks/useDiffPrevious.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import union from 'lodash/union';
import {useMemo} from 'react';
import usePrevious from './usePrevious';

/** This hook provides a list of which keys changed in an object vs the previous render
* akin to `sourceValue` for collections. Generally, using this hook at all is an anti-pattern.
* Avoid it at all costs */
export default function useDiffPrevious<T extends Record<string, unknown>>(value: T): string[] {
const previous = usePrevious(value);
const diff = useMemo(() => {
const allKeys = union(Object.keys(value), Object.keys(previous));
return allKeys.filter((key) => value[key] !== previous[key]);
}, [value, previous]);

return diff;
}
16 changes: 10 additions & 6 deletions src/hooks/useSidebarOrderedReports.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ import SidebarUtils from '@libs/SidebarUtils';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type * as OnyxTypes from '@src/types/onyx';
import {getEmptyObject} from '@src/types/utils/EmptyObject';
import mapOnyxCollectionItems from '@src/utils/mapOnyxCollectionItems';
import useCurrentReportID from './useCurrentReportID';
import useCurrentUserPersonalDetails from './useCurrentUserPersonalDetails';
import useDiffPrevious from './useDiffPrevious';
import useOnyx from './useOnyx';
import usePrevious from './usePrevious';
import useResponsiveLayout from './useResponsiveLayout';
Expand Down Expand Up @@ -61,7 +63,8 @@ function SidebarOrderedReportsContextProvider({
const [transactions, {sourceValue: transactionsUpdates}] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION, {canBeMissing: true});
const [transactionViolations, {sourceValue: transactionViolationsUpdates}] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS, {canBeMissing: true});
const [reportNameValuePairs, {sourceValue: reportNameValuePairsUpdates}] = useOnyx(ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS, {canBeMissing: true});
const [, {sourceValue: reportsDraftsUpdates}] = useOnyx(ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT, {canBeMissing: true});
const [drafts = getEmptyObject<OnyxTypes.DraftReportComments>()] = useOnyx(ONYXKEYS.NVP_DRAFT_REPORT_COMMENTS, {canBeMissing: true});
const reportsDraftsUpdates = useDiffPrevious(drafts);
const [betas] = useOnyx(ONYXKEYS.BETAS, {canBeMissing: true});
const [reportAttributes] = useOnyx(ONYXKEYS.DERIVED.REPORT_ATTRIBUTES, {selector: (value) => value?.reports, canBeMissing: true});
const [currentReportsToDisplay, setCurrentReportsToDisplay] = useState<ReportsToDisplayInLHN>({});
Expand Down Expand Up @@ -94,8 +97,8 @@ function SidebarOrderedReportsContextProvider({
reportsToUpdate = Object.keys(transactionViolationsUpdates ?? {})
.map((key) => key.replace(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS, ONYXKEYS.COLLECTION.TRANSACTION))
.map((key) => `${ONYXKEYS.COLLECTION.REPORT}${transactions?.[key]?.reportID}`);
} else if (reportsDraftsUpdates) {
reportsToUpdate = Object.keys(reportsDraftsUpdates).map((key) => key.replace(ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT, ONYXKEYS.COLLECTION.REPORT));
} else if (reportsDraftsUpdates.length > 0) {
reportsToUpdate = reportsDraftsUpdates.map((key) => `${ONYXKEYS.COLLECTION.REPORT}${key}`);
} else if (policiesUpdates) {
const updatedPolicies = Object.keys(policiesUpdates).map((key) => key.replace(ONYXKEYS.COLLECTION.POLICY, ''));
reportsToUpdate = Object.entries(chatReports ?? {})
Expand Down Expand Up @@ -146,10 +149,10 @@ function SidebarOrderedReportsContextProvider({
derivedCurrentReportID,
priorityMode === CONST.PRIORITY_MODE.GSD,
betas,
policies,
transactionViolations,
reportNameValuePairs,
reportAttributes,
drafts,
);
} else {
reportsToDisplay = SidebarUtils.getReportsToDisplayInLHN(
Expand All @@ -161,19 +164,20 @@ function SidebarOrderedReportsContextProvider({
transactionViolations,
reportNameValuePairs,
reportAttributes,
drafts,
);
}
return reportsToDisplay;
// Rule disabled intentionally — triggering a re-render on currentReportsToDisplay would cause an infinite loop
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
}, [getUpdatedReports, chatReports, derivedCurrentReportID, priorityMode, betas, policies, transactionViolations, reportNameValuePairs, reportAttributes]);
}, [getUpdatedReports, chatReports, derivedCurrentReportID, priorityMode, betas, policies, transactionViolations, reportNameValuePairs, reportAttributes, reportsDraftsUpdates]);

useEffect(() => {
setCurrentReportsToDisplay(reportsToDisplayInLHN);
}, [reportsToDisplayInLHN]);

const getOrderedReportIDs = useCallback(
() => SidebarUtils.sortReportsToDisplayInLHN(reportsToDisplayInLHN, priorityMode, reportNameValuePairs, reportAttributes),
() => SidebarUtils.sortReportsToDisplayInLHN(reportsToDisplayInLHN, priorityMode, reportNameValuePairs, reportAttributes, drafts),
// Rule disabled intentionally - reports should be sorted only when the reportsToDisplayInLHN changes
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
[reportsToDisplayInLHN],
Expand Down
6 changes: 6 additions & 0 deletions src/libs/API/parameters/SaveReportDraftCommentParams.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
type SaveReportDraftCommentParams = {
reportID: string;
comment: string;
};

export default SaveReportDraftCommentParams;
1 change: 1 addition & 0 deletions src/libs/API/parameters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -408,3 +408,4 @@ export type {default as ExportMultiLevelTagsSpreadSheetParams} from './ExportMul
export type {default as ReopenReportParams} from './ReopenReportParams';
export type {default as OpenUnreportedExpensesPageParams} from './OpenUnreportedExpensesPageParams';
export type {default as VerifyTestDriveRecipientParams} from './VerifyTestDriveRecipientParams';
export type {default as SaveReportDraftCommentParams} from './SaveReportDraftCommentParams';
2 changes: 2 additions & 0 deletions src/libs/API/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import type UpdateBeneficialOwnersForBankAccountParams from './parameters/Update
type ApiRequestType = ValueOf<typeof CONST.API_REQUEST_TYPE>;

const WRITE_COMMANDS = {
SAVE_REPORT_DRAFT_COMMENT: 'SaveReportDraftComment',
CLEAN_POLICY_TAGS: 'ClearPolicyTags',
IMPORT_MULTI_LEVEL_TAGS: 'ImportMultiLevelTags',
SET_WORKSPACE_AUTO_REPORTING_FREQUENCY: 'SetWorkspaceAutoReportingFrequency',
Expand Down Expand Up @@ -842,6 +843,7 @@ type WriteCommandParameters = {
[WRITE_COMMANDS.COMPLETE_CONCIERGE_CALL]: Parameters.CompleteConciergeCallParams;
[WRITE_COMMANDS.FINISH_CORPAY_BANK_ACCOUNT_ONBOARDING]: Parameters.FinishCorpayBankAccountOnboardingParams;
[WRITE_COMMANDS.REOPEN_REPORT]: Parameters.ReopenReportParams;
[WRITE_COMMANDS.SAVE_REPORT_DRAFT_COMMENT]: Parameters.SaveReportDraftCommentParams;

[WRITE_COMMANDS.DELETE_MONEY_REQUEST_ON_SEARCH]: Parameters.DeleteMoneyRequestOnSearchParams;
[WRITE_COMMANDS.HOLD_MONEY_REQUEST_ON_SEARCH]: Parameters.HoldMoneyRequestOnSearchParams;
Expand Down
25 changes: 9 additions & 16 deletions src/libs/DraftCommentUtils.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import type {OnyxCollection, OnyxEntry} from 'react-native-onyx';
import type {OnyxEntry} from 'react-native-onyx';
import Onyx from 'react-native-onyx';
import ONYXKEYS from '@src/ONYXKEYS';
import type {DraftReportComments} from '@src/types/onyx';

let draftCommentCollection: OnyxCollection<string> = {};
let draftComments: OnyxEntry<DraftReportComments> = {};
Onyx.connect({

Check warning on line 7 in src/libs/DraftCommentUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
Comment thread
chuckdries marked this conversation as resolved.
key: ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT,
key: ONYXKEYS.NVP_DRAFT_REPORT_COMMENTS,
callback: (nextVal) => {
draftCommentCollection = nextVal;
draftComments = nextVal;
},
waitForCollectionCallback: true,
});

/**
Expand All @@ -17,22 +17,15 @@
* A valid use-case of this function is outside React components, like in utility functions.
*/
function getDraftComment(reportID: string): OnyxEntry<string> | null | undefined {
return draftCommentCollection?.[ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT + reportID];
}

/**
* Returns true if the report has a valid draft comment.
* A valid draft comment is a non-empty string.
*/
function isValidDraftComment(comment?: string | null): boolean {
return !!comment;
return draftComments?.[reportID];
}

/**
* Returns true if the report has a valid draft comment.
* NOTE: please prefer useOnyx when possible
*/
function hasValidDraftComment(reportID: string): boolean {
return isValidDraftComment(getDraftComment(reportID));
return !!getDraftComment(reportID);
}

/**
Expand All @@ -44,4 +37,4 @@
return comment || null;
}

export {getDraftComment, isValidDraftComment, hasValidDraftComment, prepareDraftComment};
export {getDraftComment, hasValidDraftComment, prepareDraftComment};
28 changes: 23 additions & 5 deletions src/libs/SidebarUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,16 @@
import type {PartialPolicyForSidebar, ReportsToDisplayInLHN} from '@hooks/useSidebarOrderedReports';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {PersonalDetails, PersonalDetailsList, ReportActions, ReportAttributesDerivedValue, ReportNameValuePairs, Transaction, TransactionViolation} from '@src/types/onyx';
import type {
DraftReportComments,
PersonalDetails,
PersonalDetailsList,
ReportActions,
ReportAttributesDerivedValue,
ReportNameValuePairs,
Transaction,
TransactionViolation,
} from '@src/types/onyx';
import type Beta from '@src/types/onyx/Beta';
import type {ReportAttributes} from '@src/types/onyx/DerivedValues';
import type {Errors} from '@src/types/onyx/OnyxCommon';
Expand All @@ -15,7 +24,6 @@
import type ReportAction from '@src/types/onyx/ReportAction';
import {getExpensifyCardFromReportAction} from './CardMessageUtils';
import {extractCollectionItemID} from './CollectionUtils';
import {hasValidDraftComment} from './DraftCommentUtils';
import localeCompare from './LocaleCompare';
import {translateLocal} from './Localize';
import {getLastActorDisplayName, getLastMessageTextForReport, getPersonalDetailsForAccountIDs, shouldShowLastActorDisplayName} from './OptionsListUtils';
Expand Down Expand Up @@ -132,7 +140,7 @@

const visibleReportActionItems: ReportActions = {};
let allPersonalDetails: OnyxEntry<PersonalDetailsList>;
Onyx.connect({

Check warning on line 143 in src/libs/SidebarUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
callback: (value) => {
allPersonalDetails = value ?? {};
Expand All @@ -140,7 +148,7 @@
});

let allReports: OnyxCollection<Report>;
Onyx.connect({

Check warning on line 151 in src/libs/SidebarUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -148,7 +156,7 @@
},
});

Onyx.connect({

Check warning on line 159 in src/libs/SidebarUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_ACTIONS,
callback: (actions, key) => {
if (!actions || !key) {
Expand Down Expand Up @@ -207,6 +215,7 @@
transactionViolations: OnyxCollection<TransactionViolation[]>,
reportNameValuePairs?: OnyxCollection<ReportNameValuePairs>,
reportAttributes?: ReportAttributesDerivedValue['reports'],
draftReportComments?: DraftReportComments,
) {
if (!report) {
return {shouldDisplay: false};
Expand Down Expand Up @@ -238,7 +247,12 @@
const isSystemChat = isSystemChatUtil(report);
const isReportArchived = isArchivedReport(reportNameValuePairs);
const shouldOverrideHidden =
hasValidDraftComment(report.reportID) || hasErrorsOtherThanFailedReceipt || isFocused || isSystemChat || !!report.isPinned || reportAttributes?.[report?.reportID]?.requiresAttention;
!!draftReportComments?.[report.reportID] ||
hasErrorsOtherThanFailedReceipt ||
isFocused ||
isSystemChat ||
!!report.isPinned ||
reportAttributes?.[report?.reportID]?.requiresAttention;

if (isHidden && !shouldOverrideHidden) {
return {shouldDisplay: false};
Expand Down Expand Up @@ -269,6 +283,7 @@
transactionViolations: OnyxCollection<TransactionViolation[]>,
reportNameValuePairs?: OnyxCollection<ReportNameValuePairs>,
reportAttributes?: ReportAttributesDerivedValue['reports'],
draftReportComments?: DraftReportComments,
) {
const isInFocusMode = priorityMode === CONST.PRIORITY_MODE.GSD;
const allReportsDictValues = reports ?? {};
Expand All @@ -288,6 +303,7 @@
transactionViolations,
reportNameValuePairs,
reportAttributes,
draftReportComments,
);

if (shouldDisplay) {
Expand All @@ -305,10 +321,10 @@
currentReportId: string | undefined,
isInFocusMode: boolean,
betas: OnyxEntry<Beta[]>,
policies: OnyxCollection<PartialPolicyForSidebar>,
transactionViolations: OnyxCollection<TransactionViolation[]>,
reportNameValuePairs?: OnyxCollection<ReportNameValuePairs>,
reportAttributes?: ReportAttributesDerivedValue['reports'],
draftReportComments?: DraftReportComments,
) {
const displayedReportsCopy = {...displayedReports};
updatedReportsKeys.forEach((reportID) => {
Expand All @@ -326,6 +342,7 @@
transactionViolations,
reportNameValuePairs,
reportAttributes,
draftReportComments,
);

if (shouldDisplay) {
Expand All @@ -346,6 +363,7 @@
priorityMode: OnyxEntry<PriorityMode>,
reportNameValuePairs?: OnyxCollection<ReportNameValuePairs>,
reportAttributes?: ReportAttributesDerivedValue['reports'],
draftReportComments?: DraftReportComments,
): string[] {
Performance.markStart(CONST.TIMING.GET_ORDERED_REPORT_IDS);
const isInFocusMode = priorityMode === CONST.PRIORITY_MODE.GSD;
Expand Down Expand Up @@ -382,7 +400,7 @@
pinnedAndGBRReports.push(miniReport);
} else if (report?.hasErrorsOtherThanFailedReceipt) {
errorReports.push(miniReport);
} else if (hasValidDraftComment(report?.reportID)) {
} else if (draftReportComments?.[report?.reportID]) {
draftReports.push(miniReport);
} else if (isArchivedNonExpenseReport(report, !!rNVPs?.private_isArchived)) {
archivedReports.push(miniReport);
Expand Down
6 changes: 4 additions & 2 deletions src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@
};

let allPersonalDetails: OnyxTypes.PersonalDetailsList = {};
Onyx.connect({

Check warning on line 633 in src/libs/actions/IOU.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
callback: (value) => {
allPersonalDetails = value ?? {};
Expand Down Expand Up @@ -670,13 +670,13 @@
};

let allBetas: OnyxEntry<OnyxTypes.Beta[]>;
Onyx.connect({

Check warning on line 673 in src/libs/actions/IOU.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.BETAS,
callback: (value) => (allBetas = value),
});

let allTransactions: NonNullable<OnyxCollection<OnyxTypes.Transaction>> = {};
Onyx.connect({

Check warning on line 679 in src/libs/actions/IOU.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.TRANSACTION,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -690,7 +690,7 @@
});

let allTransactionDrafts: NonNullable<OnyxCollection<OnyxTypes.Transaction>> = {};
Onyx.connect({

Check warning on line 693 in src/libs/actions/IOU.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.TRANSACTION_DRAFT,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -699,7 +699,7 @@
});

let allTransactionViolations: NonNullable<OnyxCollection<OnyxTypes.TransactionViolations>> = {};
Onyx.connect({

Check warning on line 702 in src/libs/actions/IOU.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -713,7 +713,7 @@
});

let allDraftSplitTransactions: NonNullable<OnyxCollection<OnyxTypes.Transaction>> = {};
Onyx.connect({

Check warning on line 716 in src/libs/actions/IOU.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT,
waitForCollectionCallback: true,
callback: (value) => {
Expand Down Expand Up @@ -751,17 +751,19 @@
const policyID = key.replace(ONYXKEYS.COLLECTION.POLICY, '');
const policyReports = getAllPolicyReports(policyID);
const cleanUpMergeQueries: Record<`${typeof ONYXKEYS.COLLECTION.REPORT}${string}`, NullishDeep<Report>> = {};
const cleanUpSetQueries: Record<`${typeof ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT}${string}` | `${typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS_DRAFTS}${string}`, null> = {};
const cleanUpSetQueries: Record<`${typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS_DRAFTS}${string}`, null> = {};
const cleanUpDrafts: Record<string, null> = {};
Comment thread
roryabraham marked this conversation as resolved.
policyReports.forEach((policyReport) => {
if (!policyReport) {
return;
}
const {reportID} = policyReport;
cleanUpSetQueries[`${ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT}${reportID}`] = null;
cleanUpDrafts[reportID] = null;
cleanUpSetQueries[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS_DRAFTS}${reportID}`] = null;
});
Onyx.mergeCollection(ONYXKEYS.COLLECTION.REPORT, cleanUpMergeQueries);
Onyx.multiSet(cleanUpSetQueries);
Onyx.merge(ONYXKEYS.NVP_DRAFT_REPORT_COMMENTS, cleanUpDrafts);
delete allPolicies[key];
return;
}
Expand Down
Loading
Loading