The actual wording of the Law can be found at the FIDE site : -
If you then go to "E.I.01A. Laws of Chess" and look at Article 9.2 : -
'The game is drawn, upon a correct claim by the player having the move, when the same position, for at least the third time (not necessarily by a repetition of moves)
a)is about to appear, if he first writes his move on his scoresheet and declares to the arbiter his intention to make this move, or
b)has just appeared, and the player claiming the draw has the move.
Positions as in (a) and (b) are considered the same, if the same player has the move, pieces of the same kind and colour occupy the same squares, and the possible moves of all the pieces of both players are the same.
Positions are not the same if a pawn that could have been captured en passant can no longer in this manner be captured or if the right to castle has been changed temporarily or permanently.'
In particular note that it is the POSITION that has to be the same,
NOT the moves made to reach it.