Skip to content

Commit

Permalink
remove isArchivedReport param
Browse files Browse the repository at this point in the history
  • Loading branch information
gijoe0295 committed Mar 14, 2024
1 parent 220ee46 commit 5f1add8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5148,12 +5148,13 @@ function hasUpdatedTotal(report: OnyxEntry<Report>): boolean {
* - 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: OnyxEntry<ReportAction>, reportID: string, isArchivedReport = false): boolean {
function shouldDisableThread(reportAction: OnyxEntry<ReportAction>, reportID: string): boolean {
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);
const isArchivedReport = isArchivedRoom(getReport(reportID));

return (
CONST.REPORT.ACTIONS.THREAD_DISABLED.some((action: string) => action === reportAction?.actionName) ||
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/report/ContextMenu/ContextMenuActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ const ContextMenuActions: ContextMenuAction[] = [
if (type !== CONST.CONTEXT_MENU_TYPES.REPORT_ACTION) {
return false;
}
return !ReportUtils.shouldDisableThread(reportAction, reportID, isArchivedRoom);
return !ReportUtils.shouldDisableThread(reportAction, reportID);
},
onPress: (closePopover, {reportAction, reportID}) => {
if (closePopover) {
Expand Down
19 changes: 13 additions & 6 deletions tests/unit/ReportUtilsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -679,13 +679,20 @@ describe('ReportUtils', () => {
});

it('should disable on archived reports and not-thread actions', () => {
const reportAction = {
childVisibleActionCount: 1,
};
expect(ReportUtils.shouldDisableThread(reportAction, reportID, true)).toBeFalsy();
Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, {
statusNum: CONST.REPORT.STATUS_NUM.CLOSED,
stateNum: CONST.REPORT.STATE_NUM.APPROVED,
})
.then(() => waitForBatchedUpdates())
.then(() => {
const reportAction = {
childVisibleActionCount: 1,
};
expect(ReportUtils.shouldDisableThread(reportAction, reportID)).toBeFalsy();

reportAction.childVisibleActionCount = 0;
expect(ReportUtils.shouldDisableThread(reportAction, reportID, true)).toBeTruthy();
reportAction.childVisibleActionCount = 0;
expect(ReportUtils.shouldDisableThread(reportAction, reportID)).toBeTruthy();
});
});

it("should disable on a whisper action and it's neither a report preview nor IOU action", () => {
Expand Down

0 comments on commit 5f1add8

Please sign in to comment.