def _get_potentially_dirty_states(cls) -> set[type[BaseState]]:
        """Get substates which may have dirty vars due to dependencies.

        Returns:
            The set of potentially dirty substate classes.
        """
        return {
            cls.get_class_substate(substate_name)
            for substate_name in cls._always_dirty_substates
        }.union(
            {
                cls.get_root_state().get_class_substate(substate_name)
                for substate_name in cls._potentially_dirty_states
            }
        )
Get substates which may have dirty vars due to dependencies.

        Returns:
            The set of potentially dirty substate classes.
        
reflex/state.py