Skip to content

Commit eb4bffd

Browse files
committed
fix: Deleted report is shown when admin opens member's workspace chat
1 parent 0686278 commit eb4bffd

4 files changed

Lines changed: 17 additions & 6 deletions

File tree

src/libs/ReportUtils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1944,7 +1944,7 @@ function findLastAccessedReport(ignoreDomainRooms: boolean, openOnAdminRoom = fa
19441944
/**
19451945
* Whether the provided report has expenses
19461946
*/
1947-
function hasExpenses(reportID?: string, transactions?: SearchTransaction[]): boolean {
1947+
function hasExpenses(reportID?: string, transactions?: SearchTransaction[] | Transaction[]): boolean {
19481948
if (transactions) {
19491949
return !!transactions?.find((transaction) => transaction?.reportID === reportID);
19501950
}
@@ -1954,7 +1954,7 @@ function hasExpenses(reportID?: string, transactions?: SearchTransaction[]): boo
19541954
/**
19551955
* Whether the provided report is a closed expense report with no expenses
19561956
*/
1957-
function isClosedExpenseReportWithNoExpenses(report: OnyxEntry<Report>, transactions?: SearchTransaction[]): boolean {
1957+
function isClosedExpenseReportWithNoExpenses(report: OnyxEntry<Report>, transactions?: SearchTransaction[] | Transaction[]): boolean {
19581958
return report?.statusNum === CONST.REPORT.STATUS_NUM.CLOSED && isExpenseReport(report) && !hasExpenses(report.reportID, transactions);
19591959
}
19601960

src/pages/home/report/ReportActionItem.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import {clearAllRelatedReportActionErrors} from '@userActions/ReportActions';
2828
import {clearError} from '@userActions/Transaction';
2929
import type CONST from '@src/CONST';
3030
import ONYXKEYS from '@src/ONYXKEYS';
31-
import type {Report, ReportAction} from '@src/types/onyx';
31+
import type {Report, ReportAction, Transaction} from '@src/types/onyx';
3232
import type {PureReportActionItemProps} from './PureReportActionItem';
3333
import PureReportActionItem from './PureReportActionItem';
3434

@@ -38,9 +38,12 @@ type ReportActionItemProps = Omit<PureReportActionItemProps, 'taskReport' | 'lin
3838

3939
/** Whether to show the draft message or not */
4040
shouldShowDraftMessage?: boolean;
41+
42+
/** All the data of the transaction collection */
43+
transactions: Transaction[];
4144
};
4245

43-
function ReportActionItem({allReports, action, report, shouldShowDraftMessage = true, ...props}: ReportActionItemProps) {
46+
function ReportActionItem({allReports, action, report, transactions, shouldShowDraftMessage = true, ...props}: ReportActionItemProps) {
4447
const reportID = report?.reportID;
4548
const originalMessage = getOriginalMessage(action);
4649
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
@@ -109,7 +112,7 @@ function ReportActionItem({allReports, action, report, shouldShowDraftMessage =
109112
createDraftTransactionAndNavigateToParticipantSelector={createDraftTransactionAndNavigateToParticipantSelector}
110113
resolveActionableReportMentionWhisper={resolveActionableReportMentionWhisper}
111114
resolveActionableMentionWhisper={resolveActionableMentionWhisper}
112-
isClosedExpenseReportWithNoExpenses={isClosedExpenseReportWithNoExpenses(iouReport)}
115+
isClosedExpenseReportWithNoExpenses={isClosedExpenseReportWithNoExpenses(iouReport, transactions)}
113116
isCurrentUserTheOnlyParticipant={isCurrentUserTheOnlyParticipant}
114117
missingPaymentMethod={missingPaymentMethod}
115118
reimbursementDeQueuedOrCanceledActionMessage={getReimbursementDeQueuedOrCanceledActionMessage(

src/pages/home/report/ReportActionsList.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ function ReportActionsList({
166166
const isFocused = useIsFocused();
167167

168168
const [allReports] = useOnyx(ONYXKEYS.COLLECTION.REPORT, {canBeMissing: false});
169+
const [transactions] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION, {canBeMissing: false});
169170
const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID}`, {canBeMissing: true});
170171
const [accountID] = useOnyx(ONYXKEYS.SESSION, {selector: (session) => session?.accountID, canBeMissing: true});
171172
const participantsContext = useContext(PersonalDetailsContext);
@@ -596,12 +597,14 @@ function ReportActionsList({
596597
shouldDisplayReplyDivider={sortedVisibleReportActions.length > 1}
597598
isFirstVisibleReportAction={firstVisibleReportActionID === reportAction.reportActionID}
598599
shouldUseThreadDividerLine={shouldUseThreadDividerLine}
600+
transactions={transactions}
599601
/>
600602
);
601603
},
602604
[
603605
report,
604606
allReports,
607+
transactions,
605608
linkedReportActionID,
606609
sortedVisibleReportActions,
607610
mostRecentIOUReportActionID,

src/pages/home/report/ReportActionsListItemRenderer.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type {OnyxCollection, OnyxEntry} from 'react-native-onyx';
33
import {getOriginalMessage, isSentMoneyReportAction, isTransactionThread} from '@libs/ReportActionsUtils';
44
import {isChatThread, isInvoiceRoom, isPolicyExpenseChat} from '@libs/ReportUtils';
55
import CONST from '@src/CONST';
6-
import type {Report, ReportAction} from '@src/types/onyx';
6+
import type {Report, ReportAction, Transaction} from '@src/types/onyx';
77
import ReportActionItem from './ReportActionItem';
88
import ReportActionItemParentAction from './ReportActionItemParentAction';
99

@@ -17,6 +17,9 @@ type ReportActionsListItemRendererProps = {
1717
/** Array of report actions for the report */
1818
reportActions: ReportAction[];
1919

20+
/** All the data of the transaction collection */
21+
transactions: Transaction[];
22+
2023
/** The report's parentReportAction */
2124
parentReportAction: OnyxEntry<ReportAction>;
2225

@@ -61,6 +64,7 @@ function ReportActionsListItemRenderer({
6164
allReports,
6265
reportAction,
6366
reportActions = [],
67+
transactions,
6468
parentReportAction,
6569
index,
6670
report,
@@ -178,6 +182,7 @@ function ReportActionsListItemRenderer({
178182
reportActions={reportActions}
179183
linkedReportActionID={linkedReportActionID}
180184
displayAsGroup={displayAsGroup}
185+
transactions={transactions}
181186
shouldDisplayNewMarker={shouldDisplayNewMarker}
182187
shouldShowSubscriptAvatar={
183188
(isPolicyExpenseChat(report) || isInvoiceRoom(report)) &&

0 commit comments

Comments
 (0)