From 36b0cdc5a93ccd92ff2672e5b616f21bfd5a6cae Mon Sep 17 00:00:00 2001 From: Nikhil Vats Date: Sun, 13 Aug 2023 18:45:56 +0530 Subject: [PATCH 1/4] Hide reports with error from task share somewhere list --- src/libs/ReportUtils.js | 6 +++--- src/libs/SidebarUtils.js | 2 +- src/pages/home/ReportScreen.js | 2 +- src/pages/home/report/ReportActionsList.js | 2 +- src/pages/home/report/ReportFooter.js | 2 +- src/pages/iou/steps/NewRequestAmountPage.js | 2 +- src/pages/tasks/TaskShareDestinationSelectorModal.js | 3 +-- 7 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index c9fe359a7e88..85d65f84c53c 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -2841,11 +2841,11 @@ function getAddWorkspaceRoomOrChatReportErrors(report) { } /** - * Return true if the composer should be hidden + * Return true if write actions like assign task, money request, send message should be hidden on a report * @param {Object} report * @returns {Boolean} */ -function shouldHideComposer(report) { +function shouldDisableWriteActions(report) { const reportErrors = getAddWorkspaceRoomOrChatReportErrors(report); return isArchivedRoom(report) || !_.isEmpty(reportErrors) || !isAllowedToComment(report) || isAnonymousUser; } @@ -3140,7 +3140,7 @@ export { getParentReport, getTaskParentReportActionIDInAssigneeReport, getReportPreviewMessage, - shouldHideComposer, + shouldDisableWriteActions, getOriginalReportID, canAccessReport, getAddWorkspaceRoomOrChatReportErrors, diff --git a/src/libs/SidebarUtils.js b/src/libs/SidebarUtils.js index c35d4839c3f2..a6d7112336a7 100644 --- a/src/libs/SidebarUtils.js +++ b/src/libs/SidebarUtils.js @@ -257,7 +257,7 @@ function getOptionData(report, reportActions, personalDetails, preferredLocale, result.notificationPreference = report.notificationPreference || null; // If the composer is hidden then the user is not allowed to comment, same can be used to hide the draft icon. - result.isAllowedToComment = !ReportUtils.shouldHideComposer(report); + result.isAllowedToComment = !ReportUtils.shouldDisableWriteActions(report); const hasMultipleParticipants = participantPersonalDetailList.length > 1 || result.isChatRoom || result.isPolicyExpenseChat; const subtitle = ReportUtils.getChatRoomSubtitle(report); diff --git a/src/pages/home/ReportScreen.js b/src/pages/home/ReportScreen.js index c859bc6b8f05..8f4f346252e1 100644 --- a/src/pages/home/ReportScreen.js +++ b/src/pages/home/ReportScreen.js @@ -156,7 +156,7 @@ class ReportScreen extends React.Component { componentDidUpdate(prevProps) { // If composer should be hidden, hide emoji picker as well - if (ReportUtils.shouldHideComposer(this.props.report)) { + if (ReportUtils.shouldDisableWriteActions(this.props.report)) { EmojiPickerAction.hideEmojiPicker(true); } diff --git a/src/pages/home/report/ReportActionsList.js b/src/pages/home/report/ReportActionsList.js index fa94db11c4a2..ada4c464da15 100644 --- a/src/pages/home/report/ReportActionsList.js +++ b/src/pages/home/report/ReportActionsList.js @@ -156,7 +156,7 @@ function ReportActionsList(props) { // Native mobile does not render updates flatlist the changes even though component did update called. // To notify there something changes we can use extraData prop to flatlist const extraData = [props.isSmallScreenWidth ? props.newMarkerReportActionID : undefined, ReportUtils.isArchivedRoom(props.report)]; - const hideComposer = ReportUtils.shouldHideComposer(props.report); + const hideComposer = ReportUtils.shouldDisableWriteActions(props.report); const shouldShowReportRecipientLocalTime = ReportUtils.canShowReportRecipientLocalTime(props.personalDetails, props.report, props.currentUserPersonalDetails.accountID) && !props.isComposerFullSize; diff --git a/src/pages/home/report/ReportFooter.js b/src/pages/home/report/ReportFooter.js index ff4b503762e9..343f2fb87333 100644 --- a/src/pages/home/report/ReportFooter.js +++ b/src/pages/home/report/ReportFooter.js @@ -58,7 +58,7 @@ function ReportFooter(props) { const isAnonymousUser = Session.isAnonymousUser(); const isSmallSizeLayout = props.windowWidth - (props.isSmallScreenWidth ? 0 : variables.sideBarWidth) < variables.anonymousReportFooterBreakpoint; - const hideComposer = ReportUtils.shouldHideComposer(props.report); + const hideComposer = ReportUtils.shouldDisableWriteActions(props.report); return ( <> diff --git a/src/pages/iou/steps/NewRequestAmountPage.js b/src/pages/iou/steps/NewRequestAmountPage.js index ce59840e106d..9887debe0037 100644 --- a/src/pages/iou/steps/NewRequestAmountPage.js +++ b/src/pages/iou/steps/NewRequestAmountPage.js @@ -99,7 +99,7 @@ function NewRequestAmountPage({route, iou, report}) { // Check and dismiss modal useEffect(() => { - if (!ReportUtils.shouldHideComposer(report)) { + if (!ReportUtils.shouldDisableWriteActions(report)) { return; } Navigation.dismissModal(reportID); diff --git a/src/pages/tasks/TaskShareDestinationSelectorModal.js b/src/pages/tasks/TaskShareDestinationSelectorModal.js index 8272406b4cbe..1b4d4bc6730d 100644 --- a/src/pages/tasks/TaskShareDestinationSelectorModal.js +++ b/src/pages/tasks/TaskShareDestinationSelectorModal.js @@ -50,8 +50,7 @@ function TaskShareDestinationSelectorModal(props) { const reports = {}; _.keys(props.reports).forEach((reportKey) => { if ( - !ReportUtils.isAllowedToComment(props.reports[reportKey]) || - ReportUtils.isArchivedRoom(props.reports[reportKey]) || + ReportUtils.shouldDisableWriteActions(props.reports[reportKey]) || ReportUtils.isExpensifyOnlyParticipantInReport(props.reports[reportKey]) ) { return; From ae3b4a0aa8208359d06daa292b68c2072816fc74 Mon Sep 17 00:00:00 2001 From: Nikhil Vats Date: Sun, 13 Aug 2023 20:12:58 +0530 Subject: [PATCH 2/4] Fix lint issues --- src/pages/tasks/TaskShareDestinationSelectorModal.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/pages/tasks/TaskShareDestinationSelectorModal.js b/src/pages/tasks/TaskShareDestinationSelectorModal.js index 1b4d4bc6730d..1fded8d833c8 100644 --- a/src/pages/tasks/TaskShareDestinationSelectorModal.js +++ b/src/pages/tasks/TaskShareDestinationSelectorModal.js @@ -49,10 +49,7 @@ function TaskShareDestinationSelectorModal(props) { const filteredReports = useMemo(() => { const reports = {}; _.keys(props.reports).forEach((reportKey) => { - if ( - ReportUtils.shouldDisableWriteActions(props.reports[reportKey]) || - ReportUtils.isExpensifyOnlyParticipantInReport(props.reports[reportKey]) - ) { + if (ReportUtils.shouldDisableWriteActions(props.reports[reportKey]) || ReportUtils.isExpensifyOnlyParticipantInReport(props.reports[reportKey])) { return; } reports[reportKey] = props.reports[reportKey]; From 0c4ccb9805820697e31de29aea6f231d8e18e16a Mon Sep 17 00:00:00 2001 From: Nikhil Vats Date: Sun, 13 Aug 2023 23:57:21 +0530 Subject: [PATCH 3/4] NIT: change comment --- src/libs/ReportUtils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 85d65f84c53c..61e130371dd3 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -2841,7 +2841,7 @@ function getAddWorkspaceRoomOrChatReportErrors(report) { } /** - * Return true if write actions like assign task, money request, send message should be hidden on a report + * Returns true if write actions like assign task, money request, send message should be disabled on a report * @param {Object} report * @returns {Boolean} */ From 0086d150c2c768f2331025e32605936fab6a8f84 Mon Sep 17 00:00:00 2001 From: Nikhil Vats Date: Tue, 15 Aug 2023 22:04:06 +0530 Subject: [PATCH 4/4] Remove unnecessary comments --- src/libs/SidebarUtils.js | 2 -- src/pages/home/ReportScreen.js | 1 - 2 files changed, 3 deletions(-) diff --git a/src/libs/SidebarUtils.js b/src/libs/SidebarUtils.js index a6d7112336a7..8afe05650bc6 100644 --- a/src/libs/SidebarUtils.js +++ b/src/libs/SidebarUtils.js @@ -255,8 +255,6 @@ function getOptionData(report, reportActions, personalDetails, preferredLocale, result.parentReportID = report.parentReportID || null; result.isWaitingOnBankAccount = report.isWaitingOnBankAccount; result.notificationPreference = report.notificationPreference || null; - - // If the composer is hidden then the user is not allowed to comment, same can be used to hide the draft icon. result.isAllowedToComment = !ReportUtils.shouldDisableWriteActions(report); const hasMultipleParticipants = participantPersonalDetailList.length > 1 || result.isChatRoom || result.isPolicyExpenseChat; diff --git a/src/pages/home/ReportScreen.js b/src/pages/home/ReportScreen.js index 8f4f346252e1..25b22ed409a2 100644 --- a/src/pages/home/ReportScreen.js +++ b/src/pages/home/ReportScreen.js @@ -155,7 +155,6 @@ class ReportScreen extends React.Component { } componentDidUpdate(prevProps) { - // If composer should be hidden, hide emoji picker as well if (ReportUtils.shouldDisableWriteActions(this.props.report)) { EmojiPickerAction.hideEmojiPicker(true); }