Skip to content

Commit 3934efd

Browse files
mollfprOSBotify
authored andcommitted
Merge pull request #79895 from Expensify/revert-78519-fix_75276_n
[CP Staging] Revert "fix: hide categorize whisper message when categories are disabled " (cherry picked from commit 311f5a1) (cherry-picked to staging by mountiny)
1 parent b067a88 commit 3934efd

File tree

4 files changed

+4
-19
lines changed

4 files changed

+4
-19
lines changed

src/libs/OptionsListUtils/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,14 +289,13 @@ Onyx.connect({
289289
const reportNameValuePairs = allReportNameValuePairs?.[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${reportID}`];
290290
const isReportArchived = !!reportNameValuePairs?.private_isArchived;
291291
const isWriteActionAllowed = canUserPerformWriteAction(report, isReportArchived);
292-
const policy = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`];
293292

294293
// The report is only visible if it is the last action not deleted that
295294
// does not match a closed or created state.
296295
const reportActionsForDisplay = sortedReportActions.filter(
297296
(reportAction, actionKey) =>
298297
(!(isWhisperAction(reportAction) && !isReportPreviewAction(reportAction) && !isMoneyRequestAction(reportAction)) || isActionableMentionWhisper(reportAction)) &&
299-
shouldReportActionBeVisible(reportAction, actionKey, isWriteActionAllowed, policy) &&
298+
shouldReportActionBeVisible(reportAction, actionKey, isWriteActionAllowed) &&
300299
reportAction.actionName !== CONST.REPORT.ACTIONS.TYPE.CREATED &&
301300
reportAction.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE,
302301
);

src/libs/ReportActionsUtils.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,7 +1028,7 @@ function isResolvedConciergeDescriptionOptions(reportAction: OnyxEntry<ReportAct
10281028
* Checks if a reportAction is fit for display, meaning that it's not deprecated, is of a valid
10291029
* and supported type, it's not deleted and also not closed.
10301030
*/
1031-
function shouldReportActionBeVisible(reportAction: OnyxEntry<ReportAction>, key: string | number, canUserPerformWriteAction?: boolean, policy?: OnyxEntry<Policy>): boolean {
1031+
function shouldReportActionBeVisible(reportAction: OnyxEntry<ReportAction>, key: string | number, canUserPerformWriteAction?: boolean): boolean {
10321032
if (!reportAction) {
10331033
return false;
10341034
}
@@ -1101,10 +1101,6 @@ function shouldReportActionBeVisible(reportAction: OnyxEntry<ReportAction>, key:
11011101
return false;
11021102
}
11031103

1104-
if (isConciergeCategoryOptions(reportAction) && policy && !policy.areCategoriesEnabled) {
1105-
return false;
1106-
}
1107-
11081104
// All other actions are displayed except thread parents, deleted, or non-pending actions
11091105
return !!reportAction.pendingAction || !isDeletedAction(reportAction) || isDeletedParentAction(reportAction) || isReversedTransaction(reportAction);
11101106
}

src/pages/home/report/ReportActionsView.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ function ReportActionsView({
108108
const reportPreviewAction = useMemo(() => getReportPreviewAction(report.chatReportID, report.reportID), [report.chatReportID, report.reportID]);
109109
const didLayout = useRef(false);
110110
const {isOffline} = useNetwork();
111-
const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${report.policyID}`, {canBeMissing: true});
112111

113112
const {shouldUseNarrowLayout} = useResponsiveLayout();
114113
const isFocused = useIsFocused();
@@ -222,10 +221,10 @@ function ReportActionsView({
222221
reportActions.filter(
223222
(reportAction) =>
224223
(isOffline || isDeletedParentAction(reportAction) || reportAction.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE || reportAction.errors) &&
225-
shouldReportActionBeVisible(reportAction, reportAction.reportActionID, canPerformWriteAction, policy) &&
224+
shouldReportActionBeVisible(reportAction, reportAction.reportActionID, canPerformWriteAction) &&
226225
isIOUActionMatchingTransactionList(reportAction, reportTransactionIDs),
227226
),
228-
[reportActions, isOffline, canPerformWriteAction, policy, reportTransactionIDs],
227+
[reportActions, isOffline, canPerformWriteAction, reportTransactionIDs],
229228
);
230229

231230
const newestReportAction = useMemo(() => reportActions?.at(0), [reportActions]);

tests/unit/ReportActionsUtilsTest.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import {
2626
import {buildOptimisticCreatedReportForUnapprovedAction} from '../../src/libs/ReportUtils';
2727
import ONYXKEYS from '../../src/ONYXKEYS';
2828
import type {Card, OriginalMessageIOU, Report, ReportAction, ReportActions} from '../../src/types/onyx';
29-
import createRandomPolicy from '../utils/collections/policies';
3029
import createRandomReportAction from '../utils/collections/reportActions';
3130
import {createRandomReport} from '../utils/collections/reports';
3231
import * as LHNTestUtils from '../utils/LHNTestUtils';
@@ -1487,14 +1486,6 @@ describe('ReportActionsUtils', () => {
14871486
const actual = ReportActionsUtils.shouldReportActionBeVisible(reportAction, reportAction.reportActionID, true);
14881487
expect(actual).toBe(true);
14891488
});
1490-
1491-
it("should return false for concierge categorize suggestion whisper message when the policy's category feature is disabled", () => {
1492-
const reportAction: ReportAction = {...createRandomReportAction(123), actionName: CONST.REPORT.ACTIONS.TYPE.CONCIERGE_CATEGORY_OPTIONS};
1493-
const categoryFeatureDisabledPolicy = {...createRandomPolicy(1234), areCategoriesEnabled: false};
1494-
1495-
const result = ReportActionsUtils.shouldReportActionBeVisible(reportAction, reportAction.reportActionID, true, categoryFeatureDisabledPolicy);
1496-
expect(result).toBe(false);
1497-
});
14981489
});
14991490

15001491
describe('getPolicyChangeLogUpdateEmployee', () => {

0 commit comments

Comments
 (0)