How to tell if the Animator is in a subState

I’m making an idle controller, which includes a few different substates that hold different animations.

One substate would be called “PlayerSpecificIdles”, another called “SecondaryIdles”, another called “ReactionIdles”

My IdleController.cs script picks a random idle from a random substate and plays the idle according to certain conditions. I want to check if a current substate is active, so I can say if(certainSubstateIsPlaying), Don’t play an animation from ‘anotherSubstate’

this is what im using to see if a substate is active, but it’s not working

		AnimatorStateInfo currentState = characterProxy.Animator.GetCurrentAnimatorStateInfo(0);
		if(currentState.nameHash == Animator.StringToHash("SecondaryIdles")) 
		{
			Debug.Log("hit");
		}

Can you only tell if a certain clip is playing? I would like to be able to determine if Mecanim is within a substate, since there could be any number of animations within each substate.

This can easily be done with a few lines of code in Unity 5.0 and up. Please see my answer here MecAnim SubState Animation Complete - Unity Answers