Iran and Hamas are a marriage of convenience anyway. 7 October was completely independent of Iran and likely surprised and annoyed them.
According to a report I read on the BBC a while back, Western intelligence agencies believe Iran trained Hamas fighters for the attack as well as helped Hamas plan it. So I doubt Iran was "surprised" !