AiPath custom rotation problem in 2D TopDown game

Hi, sorry for my bad english!

I would like to know what could be the best way to rotate the agent in the direction of the player when it is “found”

I have tried different solutions but they all give me the same problem.

if (TargetVisible() && findPG){
      m_AIPath.enableRotation = false;
      var direction = (m_AI_Sight.player.transform.position - transform.position).normalized;
      Quaternion lookRotation = Quaternion.LookRotation(Vector3.forward, direction);
      transform.rotation = Quaternion.Slerp(transform.rotation, lookRotation, Time.deltaTime * 150);
}else{
      m_AIPath.enableRotation = true;
}

OR

if (TargetVisible() && findPG){
      m_AIPath.enableRotation = false;
      Vector2 direction = target.transform.position - transform.position;
      Quaternion toRotation = Quaternion.LookRotation(Vector3.forward, direction);
      transform.rotation = Quaternion.RotateTowards(transform.rotation, toRotation, rotationVelocity * Time.deltaTime);
}else{
      m_AIPath.enableRotation = true;
}

OR using the rotation of the AIPath without enabling or disabling rotation

if (TargetVisible() && findPG){
        Vector2 direction = m_AI_Sight.player.transform.position - gameObject.transform.position;
        Quaternion toRotation = Quaternion.LookRotation(Vector3.forward, direction);
        m_AIPath.rotation = Quaternion.RotateTowards(gameObject.transform.rotation, toRotation, 360 * Time.deltaTime);
}

In all cases, when the player turns the corner, and the player is not visible, Agent rotates too far. I’ll post a video to explain better.

Video

In the video it is noted that the enemy rotates excessively after the player crosses the corner. I think the problem is that I first force the enemy to turn towards the player and then leave the rotation control to AiPath

Do you have any suggestions? Thanks in advance