@@ -1106,7 +1106,13 @@ function isResolvedConciergeDescriptionOptions(reportAction: OnyxEntry<ReportAct
11061106 * Checks if a reportAction is fit for display, meaning that it's not deprecated, is of a valid
11071107 * and supported type, it's not deleted and also not closed.
11081108 */
1109- function shouldReportActionBeVisible ( reportAction : OnyxEntry < ReportAction > , key : string | number , canUserPerformWriteAction ?: boolean , reportsParam ?: OnyxCollection < Report > ) : boolean {
1109+ function shouldReportActionBeVisible (
1110+ reportAction : OnyxEntry < ReportAction > ,
1111+ key : string | number ,
1112+ canUserPerformWriteAction ?: boolean ,
1113+ reportsParam ?: OnyxCollection < Report > ,
1114+ policy ?: OnyxEntry < Policy > ,
1115+ ) : boolean {
11101116 if ( ! reportAction ) {
11111117 return false ;
11121118 }
@@ -1190,6 +1196,9 @@ function shouldReportActionBeVisible(reportAction: OnyxEntry<ReportAction>, key:
11901196 if ( ! isVisiblePreviewOrMoneyRequest ( reportAction ) ) {
11911197 return false ;
11921198 }
1199+ if ( policy && ! policy ?. areCategoriesEnabled && isConciergeCategoryOptions ( reportAction ) ) {
1200+ return false ;
1201+ }
11931202
11941203 // All other actions are displayed except thread parents, deleted, or non-pending actions
11951204 return ! ! reportAction . pendingAction || ! isDeletedAction ( reportAction ) || isDeletedParentAction ( reportAction ) || isReversedTransaction ( reportAction ) ;
@@ -1214,6 +1223,7 @@ function isReportActionVisible(
12141223 reportID : string ,
12151224 canUserPerformWriteAction ?: boolean ,
12161225 visibleReportActions ?: VisibleReportActionsDerivedValue ,
1226+ policy ?: OnyxEntry < Policy > ,
12171227) : boolean {
12181228 if ( ! reportAction ?. reportActionID ) {
12191229 return false ;
@@ -1223,18 +1233,18 @@ function isReportActionVisible(
12231233 // from what's cached in visibleReportActions (which reflects persisted Onyx data).
12241234 // We must recalculate visibility at runtime to ensure accuracy for these transient states.
12251235 if ( reportAction . pendingAction ) {
1226- return shouldReportActionBeVisible ( reportAction , reportAction . reportActionID , canUserPerformWriteAction ) ;
1236+ return shouldReportActionBeVisible ( reportAction , reportAction . reportActionID , canUserPerformWriteAction , undefined , policy ) ;
12271237 }
12281238
12291239 if ( visibleReportActions ) {
12301240 const reportCache = visibleReportActions [ reportID ] ;
12311241 if ( ! reportCache ) {
1232- return shouldReportActionBeVisible ( reportAction , reportAction . reportActionID , canUserPerformWriteAction ) ;
1242+ return shouldReportActionBeVisible ( reportAction , reportAction . reportActionID , canUserPerformWriteAction , undefined , policy ) ;
12331243 }
12341244 const staticVisibility = reportCache [ reportAction . reportActionID ] ;
12351245 // If action is not in derived value cache, fall back to runtime calculation
12361246 if ( staticVisibility === undefined ) {
1237- return shouldReportActionBeVisible ( reportAction , reportAction . reportActionID , canUserPerformWriteAction ) ;
1247+ return shouldReportActionBeVisible ( reportAction , reportAction . reportActionID , canUserPerformWriteAction , undefined , policy ) ;
12381248 }
12391249 if ( ! staticVisibility ) {
12401250 return false ;
@@ -1244,7 +1254,7 @@ function isReportActionVisible(
12441254 }
12451255 return true ;
12461256 }
1247- return shouldReportActionBeVisible ( reportAction , reportAction . reportActionID , canUserPerformWriteAction ) ;
1257+ return shouldReportActionBeVisible ( reportAction , reportAction . reportActionID , canUserPerformWriteAction , undefined , policy ) ;
12481258}
12491259
12501260/**
@@ -1256,6 +1266,7 @@ function isReportActionVisibleAsLastAction(
12561266 canUserPerformWriteAction ?: boolean ,
12571267 visibleReportActions ?: VisibleReportActionsDerivedValue ,
12581268 reportID ?: string ,
1269+ policy ?: OnyxEntry < Policy > ,
12591270) : boolean {
12601271 if ( ! reportAction ) {
12611272 return false ;
@@ -1273,7 +1284,7 @@ function isReportActionVisibleAsLastAction(
12731284 return (
12741285 ( ! ( isWhisperAction ( reportAction ) && ! isReportPreviewAction ( reportAction ) && ! isMoneyRequestAction ( reportAction ) && ! isModifiedExpenseAction ( reportAction ) ) ||
12751286 isActionableMentionWhisper ( reportAction ) ) &&
1276- isReportActionVisible ( reportAction , actionReportID , canUserPerformWriteAction , visibleReportActions ) &&
1287+ isReportActionVisible ( reportAction , actionReportID , canUserPerformWriteAction , visibleReportActions , policy ) &&
12771288 reportAction . actionName !== CONST . REPORT . ACTIONS . TYPE . CREATED &&
12781289 reportAction . pendingAction !== CONST . RED_BRICK_ROAD_PENDING_ACTION . DELETE
12791290 ) ;
@@ -1311,6 +1322,7 @@ function getLastVisibleAction(
13111322 actionsToMerge : Record < string , NullishDeep < ReportAction > | null > = { } ,
13121323 reportActionsParam : OnyxCollection < ReportActions > = allReportActions ,
13131324 visibleReportActionsData ?: VisibleReportActionsDerivedValue ,
1325+ policy ?: OnyxEntry < Policy > ,
13141326) : OnyxEntry < ReportAction > {
13151327 let reportActions : Array < ReportAction | null | undefined > = [ ] ;
13161328 if ( ! isEmpty ( actionsToMerge ) ) {
@@ -1324,7 +1336,7 @@ function getLastVisibleAction(
13241336 // O(n) scan to find the newest visible action, avoiding O(n log n) sort
13251337 let newest : ReportAction | undefined ;
13261338 for ( const action of reportActions ) {
1327- if ( ! action || ! isReportActionVisibleAsLastAction ( action , canUserPerformWriteAction , visibleReportActionsData , reportID ) ) {
1339+ if ( ! action || ! isReportActionVisibleAsLastAction ( action , canUserPerformWriteAction , visibleReportActionsData , reportID , policy ) ) {
13281340 continue ;
13291341 }
13301342 if ( ! newest || isNewerReportAction ( action , newest ) ) {
@@ -1344,14 +1356,15 @@ function getLastVisibleActionIncludingTransactionThread(
13441356 reportActionsParam : OnyxCollection < ReportActions > = allReportActions ,
13451357 visibleReportActionsData ?: VisibleReportActionsDerivedValue ,
13461358 transactionThreadReportID ?: string ,
1359+ policy ?: OnyxEntry < Policy > ,
13471360) : OnyxEntry < ReportAction > {
1348- const parentLastAction = getLastVisibleAction ( reportID , canUserPerformWriteAction , { } , reportActionsParam , visibleReportActionsData ) ;
1361+ const parentLastAction = getLastVisibleAction ( reportID , canUserPerformWriteAction , { } , reportActionsParam , visibleReportActionsData , policy ) ;
13491362
13501363 if ( ! transactionThreadReportID ) {
13511364 return parentLastAction ;
13521365 }
13531366
1354- const childLastAction = getLastVisibleAction ( transactionThreadReportID , canUserPerformWriteAction , { } , reportActionsParam , visibleReportActionsData ) ;
1367+ const childLastAction = getLastVisibleAction ( transactionThreadReportID , canUserPerformWriteAction , { } , reportActionsParam , visibleReportActionsData , policy ) ;
13551368
13561369 if (
13571370 childLastAction &&
@@ -1387,8 +1400,9 @@ function getLastVisibleMessage(
13871400 actionsToMerge : Record < string , NullishDeep < ReportAction > | null > = { } ,
13881401 reportAction : OnyxInputOrEntry < ReportAction > | undefined = undefined ,
13891402 visibleReportActionsData ?: VisibleReportActionsDerivedValue ,
1403+ policy ?: OnyxEntry < Policy > ,
13901404) : LastVisibleMessage {
1391- const lastVisibleAction = reportAction ?? getLastVisibleAction ( reportID , canUserPerformWriteAction , actionsToMerge , undefined , visibleReportActionsData ) ;
1405+ const lastVisibleAction = reportAction ?? getLastVisibleAction ( reportID , canUserPerformWriteAction , actionsToMerge , undefined , visibleReportActionsData , policy ) ;
13921406 const message = getReportActionMessage ( lastVisibleAction ) ;
13931407
13941408 if ( message && isReportMessageAttachment ( message ) ) {
0 commit comments