it doesn't matter what happen to the rook only the king it matter.
Castling that shouldn't have been allowed (?)
google the laws of chess that govern castling.
It's worth the time to be well-acquainted with all of them.
Only the King matters. You can't castle if your King is in check or would have to pass through check, but it doesn't matter if the Rook is targeted or passes through a targeted square.
[I deleted this message by mistake, thinking I could delete the whole thread.
In it I asked how my opponent could castle in a particular game of mine.]