@@ -211,19 +211,36 @@ export const useOrganizationsFilterMenu = ({
211211return null ;
212212} ,
213213getOptions :async ( ) => {
214- const organizationsRes = await API . getOrganizations ( ) ;
215- return organizationsRes . map < SelectFilterOption > ( ( organization ) => ( {
216- label :organization . display_name || organization . name ,
217- value :organization . name ,
218- startIcon :(
219- < UserAvatar
220- key = { organization . id }
221- size = "xs"
222- username = { organization . display_name || organization . name }
223- avatarURL = { organization . icon }
224- />
214+ // Only show the organizations for which you can view audit logs.
215+ const organizations = await API . getOrganizations ( ) ;
216+ const permissions = await API . checkAuthorization ( {
217+ checks :Object . fromEntries (
218+ organizations . map ( ( organization ) => [
219+ organization . id ,
220+ {
221+ object :{
222+ resource_type :"audit_log" ,
223+ organization_id :organization . id ,
224+ } ,
225+ action :"read" ,
226+ } ,
227+ ] ) ,
225228) ,
226- } ) ) ;
229+ } ) ;
230+ return organizations
231+ . filter ( ( organization ) => permissions [ organization . id ] )
232+ . map < SelectFilterOption > ( ( organization ) => ( {
233+ label :organization . display_name || organization . name ,
234+ value :organization . name ,
235+ startIcon :(
236+ < UserAvatar
237+ key = { organization . id }
238+ size = "xs"
239+ username = { organization . display_name || organization . name }
240+ avatarURL = { organization . icon }
241+ />
242+ ) ,
243+ } ) ) ;
227244} ,
228245} ) ;
229246} ;