Skip to content

Commit

Permalink
Merge pull request #33490 from dukenv0307/fix/31582
Browse files Browse the repository at this point in the history
Modified function to check reply in thread option
  • Loading branch information
pecanoro authored Dec 29, 2023
2 parents 4a7014b + 422f173 commit 939632e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,7 @@ const CONST = {
JOIN_ROOM: 'JOINROOM',
},
},
THREAD_DISABLED: ['CREATED'],
},
ARCHIVE_REASON: {
DEFAULT: 'default',
Expand Down
26 changes: 26 additions & 0 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4218,6 +4218,31 @@ function navigateToPrivateNotes(report: Report, session: Session) {
Navigation.navigate(ROUTES.PRIVATE_NOTES_LIST.getRoute(report.reportID));
}

/**
* Disable reply in thread action if:
*
* - The action is listed in the thread-disabled list
* - The action is a split bill action
* - The action is deleted and is not threaded
* - The action is a whisper action and it's neither a report preview nor IOU action
* - The action is the thread's first chat
*/
function shouldDisableThread(reportAction: ReportAction, reportID: string) {
const isSplitBillAction = ReportActionsUtils.isSplitBillAction(reportAction);
const isDeletedAction = ReportActionsUtils.isDeletedAction(reportAction);
const isReportPreviewAction = ReportActionsUtils.isReportPreviewAction(reportAction);
const isIOUAction = ReportActionsUtils.isMoneyRequestAction(reportAction);
const isWhisperAction = ReportActionsUtils.isWhisperAction(reportAction);

return (
CONST.REPORT.ACTIONS.THREAD_DISABLED.some((action: string) => action === reportAction.actionName) ||
isSplitBillAction ||
(isDeletedAction && !reportAction.childVisibleActionCount) ||
(isWhisperAction && !isReportPreviewAction && !isIOUAction) ||
isThreadFirstChat(reportAction, reportID)
);
}

export {
getReportParticipantsTitle,
isReportMessageAttachment,
Expand Down Expand Up @@ -4390,6 +4415,7 @@ export {
canEditWriteCapability,
hasSmartscanError,
shouldAutoFocusOnKeyPress,
shouldDisableThread,
};

export type {ExpenseOriginalMessage, OptionData, OptimisticChatReport};
12 changes: 1 addition & 11 deletions src/pages/home/report/ContextMenu/ContextMenuActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,7 @@ export default [
if (type !== CONST.CONTEXT_MENU_TYPES.REPORT_ACTION) {
return false;
}
const isCommentAction = reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT;
const isReportPreviewAction = reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.REPORTPREVIEW;
const isIOUAction = reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.IOU && !ReportActionsUtils.isSplitBillAction(reportAction);
const isModifiedExpenseAction = ReportActionsUtils.isModifiedExpenseAction(reportAction);
const isTaskAction = ReportActionsUtils.isTaskAction(reportAction);
const isWhisperAction = ReportActionsUtils.isWhisperAction(reportAction);
return (
(!isWhisperAction || isIOUAction || isReportPreviewAction) &&
(isCommentAction || isReportPreviewAction || isIOUAction || isModifiedExpenseAction || isTaskAction) &&
!ReportUtils.isThreadFirstChat(reportAction, reportID)
);
return !ReportUtils.shouldDisableThread(reportAction, reportID);
},
onPress: (closePopover, {reportAction, reportID}) => {
if (closePopover) {
Expand Down

0 comments on commit 939632e

Please sign in to comment.