gameObject.activeInHierarchy not working

I have a set of GameObjects that disables if one is enabled and I also want to disable the BoxCollider of the gameObject. the GetComponent<BoxCollider2D>().enable is not working so now Im just trying to change the size of the collider so it wont be detected in the game.
here is my code

void Start()
    {
        col = platform1.GetComponent<BoxCollider2D>();
      
    }

    

    // Update is called once per frame
    void Update()
    {
        if (platform1.activeInHierarchy == true)
        {
            col.size =new  Vector3(7.6f, 6.25f, 0);

        }
        else 
        {
            col.size = new Vector3(0, 0, 0);
        }
    }

this script is attached to the gameObject itself.

simply change to

platform1.activeSelf

also enable should be working so probably your error is somewhere else

activeInHierarchy is boolean.
you don’t need the “== true” part