Animation syntax help

Hi guys, I basically need "Debug.Log(“XXXXX”) to Run once if the conditions are met. But i dont think I am setting the conditions correctly.

Thanks in advance

if(mNavMeshAgent.tag == "Selected" && mNavMeshAgent.remainingDistance > myTargetScriptRefrence.range)   //This only works because "mNavMeshAgent.remainingDistance" was calulated the moment we right click "check above"
            {
                mNavMeshAgent.destination = myTargetScriptRefrence.focousedTarget.transform.position;

                if (mAnimator.GetBool("Running") == false || mAnimator.GetBool("UnitIsIdle") == true)
                {
                    mAnimator.SetBool("Running", true);                  //This was getting spammed
                    mAnimator.SetBool("UnitIsIdle", false);
                    Debug.Log("XXXXXXX");
                }
              
                attackSwitch = 0;

                Debug.Log("A");

            }

Just to add, Debug.A is getting spammed, and my unit remains in “UnitIsIdle” state.