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

fix: Room - Create room whisper reappears when interacting with it after workspace is deleted. #50692

Merged
merged 31 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
beb006f
fix: Room - Create room whisper reappears when interacting with it af…
Krishna2323 Oct 13, 2024
921f474
fix lint issues.
Krishna2323 Oct 13, 2024
597e243
minor update.
Krishna2323 Oct 13, 2024
352abf8
minor update.
Krishna2323 Oct 13, 2024
534c19e
fix lint issue.
Krishna2323 Oct 13, 2024
9a9ba02
Merge branch 'Expensify:main' into krishna2323/issue/49940
Krishna2323 Oct 20, 2024
176872b
Merge branch 'main' into krishna2323/issue/49940
Krishna2323 Oct 30, 2024
e602e69
pass 'canUserPerformWriteAction' to shouldReportActionBeVisible.
Krishna2323 Oct 30, 2024
7b32415
fix tests.
Krishna2323 Oct 30, 2024
16ca72b
fix: Unchanged files with check annotations.
Krishna2323 Oct 30, 2024
95bec1f
minor fixes.
Krishna2323 Oct 30, 2024
0ac8933
fix: TypeScript Checks.
Krishna2323 Oct 30, 2024
5fb1937
fix: TypeScript Checks.
Krishna2323 Oct 31, 2024
4016e70
Merge branch 'Expensify:main' into krishna2323/issue/49940
Krishna2323 Nov 1, 2024
47735bf
Merge branch 'Expensify:main' into krishna2323/issue/49940
Krishna2323 Nov 6, 2024
edf7c52
remove reportID parameter from shouldReportActionBeVisible.
Krishna2323 Nov 6, 2024
2bd8fe5
Merge branch 'Expensify:main' into krishna2323/issue/49940
Krishna2323 Nov 6, 2024
ea27cc3
remove redundant code.
Krishna2323 Nov 7, 2024
40b7435
minor update.
Krishna2323 Nov 7, 2024
606d8ad
Merge branch 'main' into krishna2323/issue/49940
Krishna2323 Nov 11, 2024
c870f75
minor update.
Krishna2323 Nov 11, 2024
dfdfb19
minor fix.
Krishna2323 Nov 13, 2024
2aacbe8
Merge branch 'Expensify:main' into krishna2323/issue/49940
Krishna2323 Nov 16, 2024
0e1da04
add tests for ReportActionsUtils.getSortedReportActionsForDisplay.
Krishna2323 Nov 16, 2024
676c822
fix unit tests.
Krishna2323 Nov 17, 2024
af332d7
minor update.
Krishna2323 Nov 17, 2024
ed6c4ff
fix tests.
Krishna2323 Nov 17, 2024
a360422
update test input data and comments.
Krishna2323 Nov 19, 2024
68d8fd6
update comments and input data.
Krishna2323 Nov 19, 2024
7d32b41
minor update.
Krishna2323 Nov 19, 2024
716c953
remove 'eslint-disable-next-line' comment.
Krishna2323 Nov 20, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ function extractAttachments(
accountID,
parentReportAction,
reportActions,
}: {privateNotes?: Record<number, Note>; accountID?: number; parentReportAction?: OnyxEntry<ReportAction>; reportActions?: OnyxEntry<ReportActions>},
reportID,
}: {privateNotes?: Record<number, Note>; accountID?: number; parentReportAction?: OnyxEntry<ReportAction>; reportActions?: OnyxEntry<ReportActions>; reportID: string},
) {
const targetNote = privateNotes?.[Number(accountID)]?.note ?? '';
const attachments: Attachment[] = [];
Expand Down Expand Up @@ -95,7 +96,7 @@ function extractAttachments(

const actions = [...(parentReportAction ? [parentReportAction] : []), ...ReportActionsUtils.getSortedReportActions(Object.values(reportActions ?? {}))];
actions.forEach((action, key) => {
if (!ReportActionsUtils.shouldReportActionBeVisible(action, key) || ReportActionsUtils.isMoneyRequestAction(action)) {
if (!ReportActionsUtils.shouldReportActionBeVisible(action, key, reportID) || ReportActionsUtils.isMoneyRequestAction(action)) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ function AttachmentCarousel({report, source, onNavigate, setDownloadButtonVisibi
const parentReportAction = report.parentReportActionID && parentReportActions ? parentReportActions[report.parentReportActionID] : undefined;
let newAttachments: Attachment[] = [];
if (type === CONST.ATTACHMENT_TYPE.NOTE && accountID) {
newAttachments = extractAttachments(CONST.ATTACHMENT_TYPE.NOTE, {privateNotes: report.privateNotes, accountID});
newAttachments = extractAttachments(CONST.ATTACHMENT_TYPE.NOTE, {privateNotes: report.privateNotes, accountID, reportID: report.reportID});
} else {
newAttachments = extractAttachments(CONST.ATTACHMENT_TYPE.REPORT, {parentReportAction, reportActions});
newAttachments = extractAttachments(CONST.ATTACHMENT_TYPE.REPORT, {parentReportAction, reportActions, reportID: report.reportID});
}

let newIndex = newAttachments.findIndex(compareImage);
Expand Down
18 changes: 15 additions & 3 deletions src/components/Attachments/AttachmentCarousel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ function AttachmentCarousel({report, source, onNavigate, setDownloadButtonVisibi
const parentReportAction = report.parentReportActionID && parentReportActions ? parentReportActions[report.parentReportActionID] : undefined;
let newAttachments: Attachment[] = [];
if (type === CONST.ATTACHMENT_TYPE.NOTE && accountID) {
newAttachments = extractAttachments(CONST.ATTACHMENT_TYPE.NOTE, {privateNotes: report.privateNotes, accountID});
newAttachments = extractAttachments(CONST.ATTACHMENT_TYPE.NOTE, {privateNotes: report.privateNotes, accountID, reportID: report.reportID});
} else {
newAttachments = extractAttachments(CONST.ATTACHMENT_TYPE.REPORT, {parentReportAction, reportActions: reportActions ?? undefined});
newAttachments = extractAttachments(CONST.ATTACHMENT_TYPE.REPORT, {parentReportAction, reportActions: reportActions ?? undefined, reportID: report.reportID});
}

if (isEqual(attachments, newAttachments)) {
Expand Down Expand Up @@ -117,7 +117,19 @@ function AttachmentCarousel({report, source, onNavigate, setDownloadButtonVisibi
onNavigate(attachment);
}
}
}, [report.privateNotes, reportActions, parentReportActions, compareImage, report.parentReportActionID, attachments, setDownloadButtonVisibility, onNavigate, accountID, type]);
}, [
report.privateNotes,
reportActions,
parentReportActions,
compareImage,
report.parentReportActionID,
attachments,
setDownloadButtonVisibility,
onNavigate,
accountID,
type,
report.reportID,
]);

// Scroll position is affected when window width is resized, so we readjust it on width changes
useEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/LHNOptionsList/LHNOptionsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ function LHNOptionsList({style, contentContainerStyles, data, onSelectRow, optio
: '-1';
const itemTransaction = transactions?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`];
const hasDraftComment = DraftCommentUtils.isValidDraftComment(draftComments?.[`${ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT}${reportID}`]);
const sortedReportActions = ReportActionsUtils.getSortedReportActionsForDisplay(itemReportActions);
const sortedReportActions = ReportActionsUtils.getSortedReportActionsForDisplay(itemReportActions, reportID);
const lastReportAction = sortedReportActions.at(0);

// Get the transaction for the last report action
Expand Down
2 changes: 1 addition & 1 deletion src/components/ParentNavigationSubtitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function ParentNavigationSubtitle({parentNavigationSubtitleData, parentReportAct
<PressableWithoutFeedback
onPress={() => {
const parentAction = ReportActionsUtils.getReportAction(parentReportID, parentReportActionID ?? '-1');
const isVisibleAction = ReportActionsUtils.shouldReportActionBeVisible(parentAction, parentAction?.reportActionID ?? '-1');
const isVisibleAction = ReportActionsUtils.shouldReportActionBeVisible(parentAction, parentAction?.reportActionID ?? '-1', parentReportID);
// Pop the thread report screen before navigating to the chat report.
Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(parentReportID));
if (isVisibleAction && !isOffline) {
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/usePaginatedReportActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function usePaginatedReportActions(reportID?: string, reportActionID?: string) {

const [sortedAllReportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportIDWithDefault}`, {
canEvict: false,
selector: (allReportActions) => ReportActionsUtils.getSortedReportActionsForDisplay(allReportActions, true),
selector: (allReportActions) => ReportActionsUtils.getSortedReportActionsForDisplay(allReportActions, reportID ?? '-1', true),
});
const [reportActionPages] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS_PAGES}${reportIDWithDefault}`);

Expand Down
6 changes: 3 additions & 3 deletions src/libs/Middleware/Pagination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type PagedResource<TResourceKey extends OnyxCollectionKey> = OnyxValues[TResourc
type PaginationCommonConfig<TResourceKey extends OnyxCollectionKey = OnyxCollectionKey, TPageKey extends OnyxPagesKey = OnyxPagesKey> = {
resourceCollectionKey: TResourceKey;
pageCollectionKey: TPageKey;
sortItems: (items: OnyxValues[TResourceKey]) => Array<PagedResource<TResourceKey>>;
sortItems: (items: OnyxValues[TResourceKey], reportID: string) => Array<PagedResource<TResourceKey>>;
getItemID: (item: PagedResource<TResourceKey>) => string;
};

Expand Down Expand Up @@ -96,7 +96,7 @@ const Pagination: Middleware = (requestResponse, request) => {

// Create a new page based on the response
const pageItems = (response.onyxData.find((data) => data.key === resourceKey)?.value ?? {}) as OnyxValues[typeof resourceCollectionKey];
const sortedPageItems = sortItems(pageItems);
const sortedPageItems = sortItems(pageItems, resourceID);
if (sortedPageItems.length === 0) {
// Must have at least 1 action to create a page.
Log.hmmm(`[Pagination] Did not receive any items in the response to ${request.command}`);
Expand All @@ -115,7 +115,7 @@ const Pagination: Middleware = (requestResponse, request) => {
const resourceCollections = resources.get(resourceCollectionKey) ?? {};
const existingItems = resourceCollections[resourceKey] ?? {};
const allItems = fastMerge(existingItems, pageItems, true);
const sortedAllItems = sortItems(allItems);
const sortedAllItems = sortItems(allItems, resourceID);

const pagesCollections = pages.get(pageCollectionKey) ?? {};
const existingPages = pagesCollections[pageKey] ?? [];
Expand Down
4 changes: 2 additions & 2 deletions src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ Onyx.connect({
// does not match a closed or created state.
const reportActionsForDisplay = sortedReportActions.filter(
(reportAction, actionKey) =>
ReportActionUtils.shouldReportActionBeVisible(reportAction, actionKey) &&
ReportActionUtils.shouldReportActionBeVisible(reportAction, actionKey, reportID) &&
!ReportActionUtils.isWhisperAction(reportAction) &&
reportAction.actionName !== CONST.REPORT.ACTIONS.TYPE.CREATED &&
reportAction.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE &&
Expand Down Expand Up @@ -677,7 +677,7 @@ function getLastMessageTextForReport(report: OnyxEntry<Report>, lastActorDetails
const iouReport = ReportUtils.getReportOrDraftReport(ReportActionUtils.getIOUReportIDFromReportActionPreview(lastReportAction));
const lastIOUMoneyReportAction = allSortedReportActions[iouReport?.reportID ?? '-1']?.find(
(reportAction, key): reportAction is ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.IOU> =>
ReportActionUtils.shouldReportActionBeVisible(reportAction, key) &&
ReportActionUtils.shouldReportActionBeVisible(reportAction, key, reportID) &&
reportAction.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE &&
ReportActionUtils.isMoneyRequestAction(reportAction),
);
Expand Down
23 changes: 16 additions & 7 deletions src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import * as PolicyUtils from './PolicyUtils';
import * as ReportConnection from './ReportConnection';
import type {OptimisticIOUReportAction, PartialReportAction} from './ReportUtils';
import {canUserPerformWriteAction, getReport} from './ReportUtils';

Check failure on line 31 in src/libs/ReportActionsUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Dependency cycle detected

Check failure on line 31 in src/libs/ReportActionsUtils.ts

View workflow job for this annotation

GitHub Actions / ESLint check

Dependency cycle detected
import StringUtils from './StringUtils';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rayane-djouah, I'm not sure how to fix this warning :(, please let me know if you have some any idea how to fix this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Krishna2323 Let's call canUserPerformWriteAction function in components instead of in the shouldReportActionBeVisible utility function and then pass a boolean to shouldReportActionBeVisible

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rayane-djouah, I found using reportID cleaner instead of using canUserPerformWriteAction in components and then passing it to shouldReportActionBeVisible but let me know if you still think the other way. I will make those changes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't use functions from ReportUtils in ReportActionsUtils because ReportUtils depends on functions from ReportActionsUtils, which would create a circular dependency.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rayane-djouah, should we create the same functions in ReportActionsUtils?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would result in code duplication. According to the author and reviewer checklist:

I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)

Therefore, we should avoid duplicating functions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's call canUserPerformWriteAction function in components instead of in the shouldReportActionBeVisible utility function and then pass a boolean to shouldReportActionBeVisible

@rayane-djouah, then we can do this but then we have to get the report using getReport function in every file which only have the reportID and then we can use canUserPerformWriteAction and pass the result to shouldReportActionBeVisible. WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using getReport function (or useOnyx hook) sounds good to me 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry for delay, will provide updates within 24hours.

// eslint-disable-next-line import/no-cycle
import * as TransactionUtils from './TransactionUtils';
Expand Down Expand Up @@ -630,7 +631,15 @@
* Checks if a reportAction is fit for display, meaning that it's not deprecated, is of a valid
* and supported type, it's not deleted and also not closed.
*/
function shouldReportActionBeVisible(reportAction: OnyxEntry<ReportAction>, key: string | number): boolean {
function shouldReportActionBeVisible(reportAction: OnyxEntry<ReportAction>, key: string | number, reportID: string): boolean {
const report = getReport(reportID);
if (
(isActionableReportMentionWhisper(reportAction) || isActionableJoinRequestPending(report?.reportID ?? '-1') || isActionableMentionWhisper(reportAction)) &&
!canUserPerformWriteAction(report)
) {
return false;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rayane-djouah, if we pass canUserPerformWriteAction boolean to shouldReportActionBeVisible then how we will get the reportID for isActionableJoinRequestPending, should we pass both?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Krishna2323 Can we use reportAction?.reportID instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rayane-djouah, reportAction?.reportID is undefined.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Krishna2323 Then I think we need to pass both

if (!reportAction) {
return false;
}
Comment on lines 639 to 641
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep this if block first

Expand Down Expand Up @@ -706,7 +715,7 @@
* Checks if a reportAction is fit for display as report last action, meaning that
* it satisfies shouldReportActionBeVisible, it's not whisper action and not deleted.
*/
function shouldReportActionBeVisibleAsLastAction(reportAction: OnyxInputOrEntry<ReportAction>): boolean {
function shouldReportActionBeVisibleAsLastAction(reportAction: OnyxInputOrEntry<ReportAction>, reportID: string): boolean {
if (!reportAction) {
return false;
}
Expand All @@ -718,7 +727,7 @@
// If a whisper action is the REPORT_PREVIEW action, we are displaying it.
// If the action's message text is empty and it is not a deleted parent with visible child actions, hide it. Else, consider the action to be displayable.
return (
shouldReportActionBeVisible(reportAction, reportAction.reportActionID) &&
shouldReportActionBeVisible(reportAction, reportAction.reportActionID, reportID) &&
!(isWhisperAction(reportAction) && !isReportPreviewAction(reportAction) && !isMoneyRequestAction(reportAction)) &&
!(isDeletedAction(reportAction) && !isDeletedParentAction(reportAction)) &&
!isResolvedActionTrackExpense(reportAction)
Expand Down Expand Up @@ -760,7 +769,7 @@
} else {
reportActions = Object.values(allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`] ?? {});
}
const visibleReportActions = reportActions.filter((action): action is ReportAction => shouldReportActionBeVisibleAsLastAction(action));
const visibleReportActions = reportActions.filter((action): action is ReportAction => shouldReportActionBeVisibleAsLastAction(action, reportID));
const sortedReportActions = getSortedReportActions(visibleReportActions, true);
if (sortedReportActions.length === 0) {
return undefined;
Expand Down Expand Up @@ -826,7 +835,7 @@
* to ensure they will always be displayed in the same order (in case multiple actions have the same timestamp).
* This is all handled with getSortedReportActions() which is used by several other methods to keep the code DRY.
*/
function getSortedReportActionsForDisplay(reportActions: OnyxEntry<ReportActions> | ReportAction[], shouldIncludeInvisibleActions = false): ReportAction[] {
function getSortedReportActionsForDisplay(reportActions: OnyxEntry<ReportActions> | ReportAction[], reportID: string, shouldIncludeInvisibleActions = false): ReportAction[] {
let filteredReportActions: ReportAction[] = [];
if (!reportActions) {
return [];
Expand All @@ -836,7 +845,7 @@
filteredReportActions = Object.values(reportActions).filter(Boolean);
} else {
filteredReportActions = Object.entries(reportActions)
.filter(([key, reportAction]) => shouldReportActionBeVisible(reportAction, key))
.filter(([key, reportAction]) => shouldReportActionBeVisible(reportAction, key, reportID))
.map(([, reportAction]) => reportAction);
}

Expand Down Expand Up @@ -1087,7 +1096,7 @@
*/
function doesReportHaveVisibleActions(reportID: string, actionsToMerge: ReportActions = {}): boolean {
const reportActions = Object.values(fastMerge(allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`] ?? {}, actionsToMerge, true));
const visibleReportActions = Object.values(reportActions ?? {}).filter((action) => shouldReportActionBeVisibleAsLastAction(action));
const visibleReportActions = Object.values(reportActions ?? {}).filter((action) => shouldReportActionBeVisibleAsLastAction(action, reportID));

// Exclude the task system message and the created message
const visibleReportActionsWithoutTaskSystemMessage = visibleReportActions.filter((action) => !isTaskAction(action) && !isCreatedAction(action));
Expand Down
2 changes: 1 addition & 1 deletion src/libs/SidebarUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Onyx.connect({
// The report is only visible if it is the last action not deleted that
// does not match a closed or created state.
const reportActionsForDisplay = actionsArray.filter(
(reportAction) => ReportActionsUtils.shouldReportActionBeVisibleAsLastAction(reportAction) && reportAction.actionName !== CONST.REPORT.ACTIONS.TYPE.CREATED,
(reportAction) => ReportActionsUtils.shouldReportActionBeVisibleAsLastAction(reportAction, reportID) && reportAction.actionName !== CONST.REPORT.ACTIONS.TYPE.CREATED,
);

const reportAction = reportActionsForDisplay.at(-1);
Expand Down
2 changes: 1 addition & 1 deletion src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ registerPaginationConfig({
nextCommand: READ_COMMANDS.GET_NEWER_ACTIONS,
resourceCollectionKey: ONYXKEYS.COLLECTION.REPORT_ACTIONS,
pageCollectionKey: ONYXKEYS.COLLECTION.REPORT_ACTIONS_PAGES,
sortItems: (reportActions) => ReportActionsUtils.getSortedReportActionsForDisplay(reportActions, true),
sortItems: (reportActions, reportID) => ReportActionsUtils.getSortedReportActionsForDisplay(reportActions, reportID, true),
getItemID: (reportAction) => reportAction.reportActionID,
});

Expand Down
2 changes: 1 addition & 1 deletion src/pages/Debug/Report/DebugReportActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function DebugReportActions({reportID}: DebugReportActionsProps) {
const styles = useThemeStyles();
const [sortedAllReportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, {
canEvict: false,
selector: (allReportActions) => ReportActionsUtils.getSortedReportActionsForDisplay(allReportActions, true),
selector: (allReportActions) => ReportActionsUtils.getSortedReportActionsForDisplay(allReportActions, reportID, true),
});
const renderItem = ({item}: ListRenderItemInfo<ReportAction>) => (
<PressableWithFeedback
Expand Down
5 changes: 4 additions & 1 deletion src/pages/home/ReportScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,10 @@ function ReportScreen({route, currentReportID = '', navigation}: ReportScreenPro
? reportActions.length > 0
: reportActions.length >= CONST.REPORT.MIN_INITIAL_REPORT_ACTION_COUNT || isPendingActionExist || (doesCreatedActionExists() && reportActions.length > 0);

const isLinkedActionDeleted = useMemo(() => !!linkedAction && !ReportActionsUtils.shouldReportActionBeVisible(linkedAction, linkedAction.reportActionID), [linkedAction]);
const isLinkedActionDeleted = useMemo(
() => !!linkedAction && !ReportActionsUtils.shouldReportActionBeVisible(linkedAction, linkedAction.reportActionID, report?.reportID ?? '-1'),
[linkedAction, report?.reportID],
);
const prevIsLinkedActionDeleted = usePrevious(linkedAction ? isLinkedActionDeleted : undefined);
const isLinkedActionInaccessibleWhisper = useMemo(
() => !!linkedAction && ReportActionsUtils.isWhisperAction(linkedAction) && !(linkedAction?.whisperedToAccountIDs ?? []).includes(currentUserAccountID),
Expand Down
6 changes: 5 additions & 1 deletion src/pages/home/report/ReportActionItemParentAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,11 @@ function ReportActionItemParentAction({
onPress={
ReportUtils.canCurrentUserOpenReport(ancestorReports.current?.[ancestor?.report?.reportID ?? '-1'])
? () => {
const isVisibleAction = ReportActionsUtils.shouldReportActionBeVisible(ancestor.reportAction, ancestor.reportAction.reportActionID ?? '-1');
const isVisibleAction = ReportActionsUtils.shouldReportActionBeVisible(
ancestor.reportAction,
ancestor.reportAction.reportActionID ?? '-1',
ancestor.report.reportID,
);
// Pop the thread report screen before navigating to the chat report.
Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(ancestor.report.reportID ?? '-1'));
if (isVisibleAction && !isOffline) {
Expand Down
4 changes: 2 additions & 2 deletions src/pages/home/report/ReportActionsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,9 @@ function ReportActionsList({
ReportActionsUtils.isDeletedParentAction(reportAction) ||
reportAction.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE ||
reportAction.errors) &&
ReportActionsUtils.shouldReportActionBeVisible(reportAction, reportAction.reportActionID),
ReportActionsUtils.shouldReportActionBeVisible(reportAction, reportAction.reportActionID, report.reportID),
),
[sortedReportActions, isOffline],
[sortedReportActions, isOffline, report.reportID],
);

/**
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/report/ReportActionsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function ReportActionsView({
const route = useRoute<RouteProp<AuthScreensParamList, typeof SCREENS.REPORT>>();
const [session] = useOnyx(ONYXKEYS.SESSION);
const [transactionThreadReportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${transactionThreadReportID ?? -1}`, {
selector: (reportActions: OnyxEntry<OnyxTypes.ReportActions>) => ReportActionsUtils.getSortedReportActionsForDisplay(reportActions, true),
selector: (reportActions: OnyxEntry<OnyxTypes.ReportActions>) => ReportActionsUtils.getSortedReportActionsForDisplay(reportActions, report.reportID, true),
});
const [transactionThreadReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReportID ?? -1}`);
const prevTransactionThreadReport = usePrevious(transactionThreadReport);
Expand Down
Loading
Loading