From ddc6d7ac7bb0521110219b7d08041913e7b57e39 Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Thu, 19 Sep 2024 00:48:33 +0530 Subject: [PATCH 01/10] adds v1 changes --- .../MoneyRequestConfirmationList.tsx | 2 + src/libs/OptionsListUtils.ts | 53 +++++++++++++++++++ src/libs/ReportUtils.ts | 2 + src/libs/actions/Report.ts | 6 +++ 4 files changed, 63 insertions(+) diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index 743a5b276c98..5f9f3f35e8b6 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -654,6 +654,8 @@ function MoneyRequestConfirmationList({ isSelected: false, isInteractive: !shouldDisableParticipant(participant), })); + + // console.log('formattedSelectedParticipants', formattedSelectedParticipants); options.push({ title: translate('common.to'), data: formattedSelectedParticipants, diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index afedd308371c..ac78c3c75d48 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -10,6 +10,7 @@ import type {OnyxCollection, OnyxEntry} from 'react-native-onyx'; import type {SetNonNullable} from 'type-fest'; import {FallbackAvatar} from '@components/Icon/Expensicons'; import type {SelectedTagOption} from '@components/TagPicker'; +import {createDraftReportForPolicyExpenseChat} from '@libs/actions/Report'; import type {IOUAction} from '@src/CONST'; import CONST from '@src/CONST'; import type {TranslationPaths} from '@src/languages/types'; @@ -61,6 +62,7 @@ import * as UserUtils from './UserUtils'; type SearchOption = ReportUtils.OptionData & { item: T; + isOptimisticReportOption?: boolean; }; type OptionList = { @@ -239,6 +241,13 @@ Onyx.connect({ }, }); +let allReportsDraft: OnyxCollection; +Onyx.connect({ + key: ONYXKEYS.COLLECTION.REPORT_DRAFT, + waitForCollectionCallback: true, + callback: (value) => (allReportsDraft = value), +}); + let loginList: OnyxEntry; Onyx.connect({ key: ONYXKEYS.LOGIN_LIST, @@ -1516,6 +1525,7 @@ function isReportSelected(reportOption: ReportUtils.OptionData, selectedOptions: function createOptionList(personalDetails: OnyxEntry, reports?: OnyxCollection) { const reportMapForAccountIDs: Record = {}; const allReportOptions: Array> = []; + const policyToReportForPolicyExpenseChats: Record = {}; if (reports) { Object.values(reports).forEach((report) => { @@ -1531,6 +1541,10 @@ function createOptionList(personalDetails: OnyxEntry, repor return; } + if (ReportUtils.isPolicyExpenseChat(report) && report.policyID) { + policyToReportForPolicyExpenseChats[report.policyID] = report; + } + // Save the report in the map if this is a single participant so we can associate the reportID with the // personal detail option later. Individuals should not be associated with single participant // policyExpenseChats or chatRooms since those are not people. @@ -1545,6 +1559,45 @@ function createOptionList(personalDetails: OnyxEntry, repor }); } + const policiesWithoutExpenseChats = Object.values(policies ?? {}).filter((policy) => { + if (policy?.type === CONST.POLICY.TYPE.PERSONAL || !policy?.isPolicyExpenseChatEnabled) { + return false; + } + return !policyToReportForPolicyExpenseChats[policy?.id ?? '']; + }); + + // go through each policy and create a optimistic report option for it + if (policiesWithoutExpenseChats && policiesWithoutExpenseChats.length > 0) { + policiesWithoutExpenseChats.forEach((policy) => { + // check for draft report exist in allreportDrafts for the policy + let draftReport = Object.values(allReportsDraft ?? {})?.find((reportDraft) => reportDraft?.policyID === policy?.id); + if (!draftReport) { + draftReport = ReportUtils.buildOptimisticChatReport( + [currentUserAccountID ?? -1], + '', + CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT, + policy?.id, + currentUserAccountID, + true, + policy?.name, + undefined, + undefined, + undefined, + undefined, + undefined, + undefined, + undefined, + undefined, + ); + createDraftReportForPolicyExpenseChat({...draftReport, isOptimisticReport: true}); + } + const accountIDs = ReportUtils.getParticipantsAccountIDsForDisplay(draftReport); + allReportOptions.push({ + item: draftReport, + ...createOption(accountIDs, personalDetails, draftReport, {}), + }); + }); + } const allPersonalDetailsOptions = Object.values(personalDetails ?? {}).map((personalDetail) => ({ item: personalDetail, ...createOption([personalDetail?.accountID ?? -1], personalDetails, reportMapForAccountIDs[personalDetail?.accountID ?? -1], {}, {showPersonalDetails: true}), diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index f37f3f940516..b408519e4c3a 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -267,6 +267,7 @@ type OptimisticChatReport = Pick< | 'chatReportID' | 'iouReportID' | 'isOwnPolicyExpenseChat' + | 'isPolicyExpenseChat' | 'isPinned' | 'lastActorAccountID' | 'lastMessageTranslationKey' @@ -5099,6 +5100,7 @@ function buildOptimisticChatReport( chatType, isOwnPolicyExpenseChat, isPinned: isNewlyCreatedWorkspaceChat, + isPolicyExpenseChat: chatType === CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT, lastActorAccountID: 0, lastMessageTranslationKey: '', lastMessageHtml: '', diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index caaf6840e56d..72b1a41646a6 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -76,6 +76,7 @@ import processReportIDDeeplink from '@libs/processReportIDDeeplink'; import * as Pusher from '@libs/Pusher/pusher'; import * as ReportActionsUtils from '@libs/ReportActionsUtils'; import * as ReportConnection from '@libs/ReportConnection'; +import type {OptimisticChatReport} from '@libs/ReportUtils'; import type {OptimisticAddCommentReportAction} from '@libs/ReportUtils'; import * as ReportUtils from '@libs/ReportUtils'; import {doesReportBelongToWorkspace} from '@libs/ReportUtils'; @@ -4097,6 +4098,10 @@ function markAsManuallyExported(reportID: string, connectionName: ConnectionName API.write(WRITE_COMMANDS.MARK_AS_EXPORTED, params, {optimisticData, successData, failureData}); } +function createDraftReportForPolicyExpenseChat(draftReport: OptimisticChatReport) { + Onyx.set(`${ONYXKEYS.COLLECTION.REPORT_DRAFT}${draftReport.reportID}`, draftReport); +} + export type {Video}; export { @@ -4185,4 +4190,5 @@ export { exportToIntegration, markAsManuallyExported, handleReportChanged, + createDraftReportForPolicyExpenseChat, }; From db274ef4410788b033cc48587e2c37fc07d4749f Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Thu, 19 Sep 2024 01:15:38 +0530 Subject: [PATCH 02/10] lint fix --- src/libs/OptionsListUtils.ts | 2 +- src/libs/actions/Report.ts | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index ac78c3c75d48..64b38e831d2c 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -10,7 +10,6 @@ import type {OnyxCollection, OnyxEntry} from 'react-native-onyx'; import type {SetNonNullable} from 'type-fest'; import {FallbackAvatar} from '@components/Icon/Expensicons'; import type {SelectedTagOption} from '@components/TagPicker'; -import {createDraftReportForPolicyExpenseChat} from '@libs/actions/Report'; import type {IOUAction} from '@src/CONST'; import CONST from '@src/CONST'; import type {TranslationPaths} from '@src/languages/types'; @@ -41,6 +40,7 @@ import type * as OnyxCommon from '@src/types/onyx/OnyxCommon'; import type DeepValueOf from '@src/types/utils/DeepValueOf'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import times from '@src/utils/times'; +import {createDraftReportForPolicyExpenseChat} from './actions/Report'; import Timing from './actions/Timing'; import * as ErrorUtils from './ErrorUtils'; import filterArrayByMatch from './filterArrayByMatch'; diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 72b1a41646a6..fb6cd7dc4168 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -76,8 +76,7 @@ import processReportIDDeeplink from '@libs/processReportIDDeeplink'; import * as Pusher from '@libs/Pusher/pusher'; import * as ReportActionsUtils from '@libs/ReportActionsUtils'; import * as ReportConnection from '@libs/ReportConnection'; -import type {OptimisticChatReport} from '@libs/ReportUtils'; -import type {OptimisticAddCommentReportAction} from '@libs/ReportUtils'; +import type {OptimisticAddCommentReportAction, OptimisticChatReport} from '@libs/ReportUtils'; import * as ReportUtils from '@libs/ReportUtils'; import {doesReportBelongToWorkspace} from '@libs/ReportUtils'; import shouldSkipDeepLinkNavigation from '@libs/shouldSkipDeepLinkNavigation'; From 2c3224b5d1a5cf6d9d0de6b4544edab193e73733 Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Thu, 19 Sep 2024 01:21:06 +0530 Subject: [PATCH 03/10] remove undesired changes --- src/components/MoneyRequestConfirmationList.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index 5f9f3f35e8b6..743a5b276c98 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -654,8 +654,6 @@ function MoneyRequestConfirmationList({ isSelected: false, isInteractive: !shouldDisableParticipant(participant), })); - - // console.log('formattedSelectedParticipants', formattedSelectedParticipants); options.push({ title: translate('common.to'), data: formattedSelectedParticipants, From eee62507fabbbd9a4a6b794e2b8a20508ec34570 Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Thu, 19 Sep 2024 03:49:09 +0530 Subject: [PATCH 04/10] remove option from other lists --- src/libs/OptionsListUtils.ts | 8 ++++++++ .../iou/request/MoneyRequestParticipantsSelector.tsx | 1 + 2 files changed, 9 insertions(+) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 64b38e831d2c..45c659cf5c6d 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -181,6 +181,7 @@ type GetOptionsConfig = { includeDomainEmail?: boolean; action?: IOUAction; shouldBoldTitleByDefault?: boolean; + includePoliciesWithoutExpenseChats?: boolean; }; type GetUserToInviteConfig = { @@ -1594,6 +1595,7 @@ function createOptionList(personalDetails: OnyxEntry, repor const accountIDs = ReportUtils.getParticipantsAccountIDsForDisplay(draftReport); allReportOptions.push({ item: draftReport, + isOptimisticReportOption: true, ...createOption(accountIDs, personalDetails, draftReport, {}), }); }); @@ -1797,6 +1799,7 @@ function getOptions( includeDomainEmail = false, action, shouldBoldTitleByDefault = true, + includePoliciesWithoutExpenseChats = false, }: GetOptionsConfig, ): Options { if (includeCategories) { @@ -1861,6 +1864,9 @@ function getOptions( // Filter out all the reports that shouldn't be displayed const filteredReportOptions = options.reports.filter((option) => { + if (option.isOptimisticReportOption && !includePoliciesWithoutExpenseChats) { + return; + } const report = option.item; const doesReportHaveViolations = shouldShowViolations(report, transactionViolations); @@ -2191,6 +2197,7 @@ function getFilteredOptions( includeInvoiceRooms = false, action: IOUAction | undefined = undefined, sortByReportTypeInSearch = false, + includePoliciesWithoutExpenseChats = false, ) { return getOptions( {reports, personalDetails}, @@ -2220,6 +2227,7 @@ function getFilteredOptions( includeInvoiceRooms, action, sortByReportTypeInSearch, + includePoliciesWithoutExpenseChats, }, ); } diff --git a/src/pages/iou/request/MoneyRequestParticipantsSelector.tsx b/src/pages/iou/request/MoneyRequestParticipantsSelector.tsx index f10575f8c1d0..247b413da319 100644 --- a/src/pages/iou/request/MoneyRequestParticipantsSelector.tsx +++ b/src/pages/iou/request/MoneyRequestParticipantsSelector.tsx @@ -130,6 +130,7 @@ function MoneyRequestParticipantsSelector({participants = CONST.EMPTY_ARRAY, onF iouType === CONST.IOU.TYPE.INVOICE, action, isPaidGroupPolicy, + true, ); return optionList; From 6d09fcc026dd5e7091d51619b5b08aefaace80c6 Mon Sep 17 00:00:00 2001 From: Ishpaul Singh <104348397+ishpaul777@users.noreply.github.com> Date: Mon, 14 Oct 2024 23:31:53 +0530 Subject: [PATCH 05/10] Update src/libs/OptionsListUtils.ts Co-authored-by: Puneet Lath --- src/libs/OptionsListUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index f4dad4892014..6f32e843cd10 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -1637,7 +1637,7 @@ function createOptionList(personalDetails: OnyxEntry, repor } const policiesWithoutExpenseChats = Object.values(policies ?? {}).filter((policy) => { - if (policy?.type === CONST.POLICY.TYPE.PERSONAL || !policy?.isPolicyExpenseChatEnabled) { + if (policy?.type === CONST.POLICY.TYPE.PERSONAL) { return false; } return !policyToReportForPolicyExpenseChats[policy?.id ?? '']; From c68ffae202da07d52b68b22492090c1601eedc79 Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Tue, 15 Oct 2024 23:33:09 +0530 Subject: [PATCH 06/10] add policy id request params --- src/libs/API/parameters/RequestMoneyParams.ts | 1 + src/libs/actions/IOU.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/src/libs/API/parameters/RequestMoneyParams.ts b/src/libs/API/parameters/RequestMoneyParams.ts index e3e600a4e367..27e1032d82a9 100644 --- a/src/libs/API/parameters/RequestMoneyParams.ts +++ b/src/libs/API/parameters/RequestMoneyParams.ts @@ -28,6 +28,7 @@ type RequestMoneyParams = { transactionThreadReportID: string; createdReportActionIDForThread: string; reimbursible?: boolean; + policyID?: string; }; export default RequestMoneyParams; diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index bb20bac720c9..604dd3b6fc29 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -3627,6 +3627,7 @@ function requestMoney( transactionThreadReportID, createdReportActionIDForThread, reimbursible, + policyID: policy?.id, }; // eslint-disable-next-line rulesdir/no-multiple-api-calls From 7fc0571e2dfb9f7e8689f45c3dbc1950d9b1ee2c Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Wed, 16 Oct 2024 00:53:49 +0530 Subject: [PATCH 07/10] fix tests --- tests/unit/OptionsListUtilsTest.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/unit/OptionsListUtilsTest.ts b/tests/unit/OptionsListUtilsTest.ts index d94303b98124..8a111e305fcf 100644 --- a/tests/unit/OptionsListUtilsTest.ts +++ b/tests/unit/OptionsListUtilsTest.ts @@ -407,9 +407,9 @@ describe('OptionsListUtils', () => { const results = OptionsListUtils.getSearchOptions(OPTIONS, '', [CONST.BETAS.ALL]); // Then the 2 personalDetails that don't have reports should be returned expect(results.personalDetails.length).toBe(2); - // Then all of the reports should be shown including the archived rooms. - expect(results.recentReports.length).toBe(Object.values(OPTIONS.reports).length); + // - 1 because when we create the option list we also create a workspace chat optimistic options for the old oldot policies or polices with isPolicyExpenseChatEnabled: false, in this case we have a policy "Hero Policy" with isPolicyExpenseChatEnabled: false, More info: https://github.com/Expensify/App/issues/49344 + expect(results.recentReports.length).toBe(Object.values(OPTIONS.reports).length - 1); }); it('getFilteredOptions()', () => { @@ -593,8 +593,8 @@ describe('OptionsListUtils', () => { // When we pass an empty search value let results = OptionsListUtils.getShareDestinationOptions(filteredReports, OPTIONS.personalDetails, [], ''); - // Then we should expect all the recent reports to show but exclude the archived rooms - expect(results.recentReports.length).toBe(Object.values(OPTIONS.reports).length - 1); + // Then we should expect all the recent reports to show but exclude the archived rooms and workspace policy chat report + expect(results.recentReports.length).toBe(Object.values(OPTIONS.reports).length - 2); // Filter current REPORTS_WITH_WORKSPACE_ROOMS as we do in the component, before getting share destination options const filteredReportsWithWorkspaceRooms = Object.values(OPTIONS_WITH_WORKSPACE_ROOM.reports).reduce((filtered, option) => { @@ -609,8 +609,8 @@ describe('OptionsListUtils', () => { // When we also have a policy to return rooms in the results results = OptionsListUtils.getShareDestinationOptions(filteredReportsWithWorkspaceRooms, OPTIONS.personalDetails, [], ''); // Then we should expect the DMS, the group chats and the workspace room to show - // We should expect all the recent reports to show, excluding the archived rooms - expect(results.recentReports.length).toBe(Object.values(OPTIONS_WITH_WORKSPACE_ROOM.reports).length - 1); + // We should expect all the recent reports to show, excluding the archived rooms and workspace policy chat report + expect(results.recentReports.length).toBe(Object.values(OPTIONS_WITH_WORKSPACE_ROOM.reports).length - 2); }); it('getMemberInviteOptions()', () => { From 3a1a1513612c40b0883acb6ebf72a76e21bad220 Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Fri, 18 Oct 2024 01:24:27 +0530 Subject: [PATCH 08/10] fixes real/draft policy issue --- .../request/step/IOURequestStepConfirmation.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx index e8fc138f6a52..26d3e918ed90 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx @@ -55,13 +55,17 @@ function IOURequestStepConfirmation({ const currentUserPersonalDetails = useCurrentUserPersonalDetails(); const personalDetails = usePersonalDetails() || CONST.EMPTY_OBJECT; - const [policyDraft] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_DRAFTS}${IOU.getIOURequestPolicyID(transaction, reportDraft)}`); - const [policyReal] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${IOU.getIOURequestPolicyID(transaction, reportReal)}`); - const [policyCategoriesReal] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${IOU.getIOURequestPolicyID(transaction, reportReal)}`); - const [policyCategoriesDraft] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${IOU.getIOURequestPolicyID(transaction, reportDraft)}`); - const [policyTags] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_TAGS}${IOU.getIOURequestPolicyID(transaction, reportReal)}`); + const policyIDForReal = IOU.getIOURequestPolicyID(transaction, reportReal ?? reportDraft); + const policyIDForDraft = IOU.getIOURequestPolicyID(transaction, reportDraft); + + const [policyReal] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyIDForReal}`); + const [policyDraft] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyIDForDraft}`); + const [policyCategoriesReal] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyIDForReal}`); + const [policyCategoriesDraft] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyIDForDraft}`); + const [policyTags] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyIDForReal}`); const report = reportReal ?? reportDraft; + // Check if the real policy exists for either reportReal or reportDraft const policy = policyReal ?? policyDraft; const policyCategories = policyCategoriesReal ?? policyCategoriesDraft; From c42adc3229b5a23278512cd3e86b1e3dbd3ead34 Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Fri, 18 Oct 2024 01:34:56 +0530 Subject: [PATCH 09/10] formatting and typo fix --- src/libs/actions/Report.ts | 3 +-- src/pages/iou/request/step/IOURequestStepConfirmation.tsx | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 99616cfa412e..a919534ad90b 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -4125,10 +4125,9 @@ function markAsManuallyExported(reportID: string, connectionName: ConnectionName API.write(WRITE_COMMANDS.MARK_AS_EXPORTED, params, {optimisticData, successData, failureData}); } - function createDraftReportForPolicyExpenseChat(draftReport: OptimisticChatReport) { Onyx.set(`${ONYXKEYS.COLLECTION.REPORT_DRAFT}${draftReport.reportID}`, draftReport); -} +} function exportReportToCSV({reportID, transactionIDList}: ExportReportCSVParams, onDownloadFailed: () => void) { const finalParameters = enhanceParameters(WRITE_COMMANDS.EXPORT_REPORT_TO_CSV, { diff --git a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx index 26d3e918ed90..9d2123d232b0 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx @@ -59,7 +59,7 @@ function IOURequestStepConfirmation({ const policyIDForDraft = IOU.getIOURequestPolicyID(transaction, reportDraft); const [policyReal] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyIDForReal}`); - const [policyDraft] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyIDForDraft}`); + const [policyDraft] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_DRAFTS}${policyIDForDraft}`); const [policyCategoriesReal] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyIDForReal}`); const [policyCategoriesDraft] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyIDForDraft}`); const [policyTags] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyIDForReal}`); From 4b84b280e57c1f9f5109b3ce335a1807b8aa29aa Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Fri, 18 Oct 2024 02:23:25 +0530 Subject: [PATCH 10/10] delete actions of report if there is preexisting report --- src/libs/actions/Report.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index a919534ad90b..f0b0fd4adc5f 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -1368,6 +1368,7 @@ function handleReportChanged(report: OnyxEntry) { if (report?.reportID && report.preexistingReportID) { let callback = () => { Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${report.reportID}`, null); + Onyx.set(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.reportID}`, null); Onyx.set(`${ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT}${report.reportID}`, null); }; // Only re-route them if they are still looking at the optimistically created report