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

Hide reports with error from task share somewhere list #24506

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2968,11 +2968,11 @@ function getAddWorkspaceRoomOrChatReportErrors(report) {
}

/**
* Return true if the composer should be hidden
* Returns true if write actions like assign task, money request, send message should be disabled on a report
* @param {Object} report
* @returns {Boolean}
*/
function shouldHideComposer(report) {
function shouldDisableWriteActions(report) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not against this naming. But will defer to @arosiclair

const reportErrors = getAddWorkspaceRoomOrChatReportErrors(report);
return isArchivedRoom(report) || !_.isEmpty(reportErrors) || !isAllowedToComment(report) || isAnonymousUser;
}
Expand Down Expand Up @@ -3269,7 +3269,7 @@ export {
getTaskParentReportActionIDInAssigneeReport,
getReportPreviewMessage,
getModifiedExpenseMessage,
shouldHideComposer,
shouldDisableWriteActions,
getOriginalReportID,
canAccessReport,
getAddWorkspaceRoomOrChatReportErrors,
Expand Down
4 changes: 1 addition & 3 deletions src/libs/SidebarUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,7 @@ 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.shouldHideComposer(report);
result.isAllowedToComment = !ReportUtils.shouldDisableWriteActions(report);

const hasMultipleParticipants = participantPersonalDetailList.length > 1 || result.isChatRoom || result.isPolicyExpenseChat;
const subtitle = ReportUtils.getChatRoomSubtitle(report);
Expand Down
3 changes: 1 addition & 2 deletions src/pages/home/ReportScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,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);
}

Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/report/ReportActionsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/report/ReportFooter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/iou/steps/NewRequestAmountPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 1 addition & 5 deletions src/pages/tasks/TaskShareDestinationSelectorModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,7 @@ function TaskShareDestinationSelectorModal(props) {
const filteredReports = useMemo(() => {
const reports = {};
_.keys(props.reports).forEach((reportKey) => {
if (
!ReportUtils.isAllowedToComment(props.reports[reportKey]) ||
ReportUtils.isArchivedRoom(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];
Expand Down