Quaternion slerp loop exits before equality of quaternions

The loop involves 3 transforms: playerBody, playerHTP and playerVTP which is a child object of playerHTP. I want all 3 of them to have the same rotation which is the rotation that playerBody has. So I created a while loop that slerps playerHTP to playerBody, and simultaneously slerps playerVTP to a local rotation of Quaternion.Euler(0,0,0). It works sometimes but other times it does not work which is why I cannot understand what is going wrong? I guess it has something to do with different cases of playerBody’s rotation but I dont understand why different rotations of playerBody are reacting differently. Here is my code:

        while (playerHTP.transform.rotation != playerBody.transform.rotation && playerVTP.transform.localRotation != Quaternion.Euler(0, 0, 0))
        {
            if (playerHTP.transform.rotation != playerBody.transform.rotation)
                playerHTP.transform.rotation = Quaternion.Slerp(playerHTP.transform.rotation, playerBody.transform.rotation, 5 * Time.deltaTime);
            Debug.Log("HTP rotation: " + playerHTP.transform.rotation + " player rotation: " + playerBody.transform.rotation);
            if (playerVTP.transform.localRotation != Quaternion.Euler(0, 0, 0))
                playerVTP.transform.localRotation = Quaternion.Slerp(playerVTP.transform.localRotation, Quaternion.Euler(0, 0, 0), 5 * Time.deltaTime);
            Debug.Log("VTP rotation: " + playerVTP.transform.localRotation);
            yield return null;
        }

EDIT: I tried this code and it gave more accurate results but still the same issue happens sometimes:

float time = 0f;
        Quaternion initPlayerRot = playerBody.transform.rotation;
        Quaternion initPlayerHTPRot = playerHTP.transform.rotation;
        Quaternion initPlayerVTPRot = playerVTP.transform.localRotation;
        while (playerHTP.transform.rotation != playerBody.transform.rotation && playerVTP.transform.localRotation != Quaternion.Euler(0, 0, 0))
        {
            playerHTP.transform.rotation = Quaternion.Slerp(initPlayerHTPRot,initPlayerRot,time);
            playerVTP.transform.localRotation = Quaternion.Slerp(initPlayerVTPRot,Quaternion.Euler(0, 0, 0),time);
            time += 5*Time.deltaTime;
            yield return null;
        }

The issue only occurs sometimes that is why I believe it is something to do with specific values of quaternion rotations. If it was some other part of my code causing it, it would happen everytime.

I also confirmed this with the Debug.Log() that you see. I added the ones in the code and a final one after the loop was over to notify me that the loop has exited. As I expected, when the rotations happened correctly, the loop exited after equal quaternion values being printed (equal for playerBody and playerHTP, and (0,0,0,1) for playerVTP as it was local rotation) , and when wrong rotations happened, the output values were unequal.

This loop is executed when my player enters a trigger and it can enter it at any angle it wants which is why the Quaternions vary based on the current play through. That is the only possible reason I can think of why this happens only sometimes

the first code is simply wrong, the second looks fine to me, are you sure it is not working? can you change the while statement

 while (playerHTP.transform.rotation != playerBody.transform.rotation && playerVTP.transform.localRotation != Quaternion.Euler(0, 0, 0))

to

do
{
} while(timer < 1);