diff --git a/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/setup_technology_selector/use_setup_technology.ts b/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/setup_technology_selector/use_setup_technology.ts index 5cb6bb17613fd..20c104fc071c9 100644 --- a/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/setup_technology_selector/use_setup_technology.ts +++ b/x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/setup_technology_selector/use_setup_technology.ts @@ -50,10 +50,11 @@ export const useSetupTechnology = ({ return; } - if ( - agentPolicyIds.length > 0 && - (!agentlessPolicyId || !agentPolicyIds.includes(agentlessPolicyId)) - ) { + const hasAgentPolicies = agentPolicyIds.length > 0; + const agentlessPolicyIsAbsent = + !agentlessPolicyId || !agentPolicyIds.includes(agentlessPolicyId); + + if (hasAgentPolicies && agentlessPolicyIsAbsent) { /* handle case when agent policy is coming from outside, e.g. from the get param or when coming to integration from a specific agent policy