-
Notifications
You must be signed in to change notification settings - Fork 3k
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
fix: Room - Create room whisper reappears when interacting with it after workspace is deleted. #50692
Changes from 5 commits
beb006f
921f474
597e243
352abf8
534c19e
9a9ba02
176872b
e602e69
7b32415
16ca72b
95bec1f
0ac8933
5fb1937
4016e70
47735bf
edf7c52
2bd8fe5
ea27cc3
40b7435
606d8ad
c870f75
dfdfb19
2aacbe8
0e1da04
676c822
af332d7
ed6c4ff
a360422
68d8fd6
7d32b41
716c953
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 GitHub Actions / Changed files ESLint check
|
||
import StringUtils from './StringUtils'; | ||
// eslint-disable-next-line import/no-cycle | ||
import * as TransactionUtils from './TransactionUtils'; | ||
|
@@ -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; | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @rayane-djouah, if we pass There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Krishna2323 Can we use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @rayane-djouah, There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's keep this if block first |
||
|
@@ -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; | ||
} | ||
|
@@ -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) | ||
|
@@ -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; | ||
|
@@ -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 []; | ||
|
@@ -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); | ||
} | ||
|
||
|
@@ -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)); | ||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 theshouldReportActionBeVisible
utility function and then pass a boolean toshouldReportActionBeVisible
There was a problem hiding this comment.
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 usingcanUserPerformWriteAction
in components and then passing it toshouldReportActionBeVisible
but let me know if you still think the other way. I will make those changes.There was a problem hiding this comment.
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
inReportActionsUtils
becauseReportUtils
depends on functions fromReportActionsUtils
, which would create a circular dependency.There was a problem hiding this comment.
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
?There was a problem hiding this comment.
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:
Therefore, we should avoid duplicating functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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 usecanUserPerformWriteAction
and pass the result toshouldReportActionBeVisible
. WDYT?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using
getReport
function (oruseOnyx
hook) sounds good to me 👍There was a problem hiding this comment.
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.