If one thinks about it, it was very likely that it was planted well in advance. It was known where Haniyeh stayed when he visited Tehran, but not necessarily when he would visit. So the bomb pretty much had to have been there weeks in advance, "waiting" for Haniyeh to visit. That time separation also gives some protection for the one who planted it by masking when it was planted and by whom.
The Mullahcracy rules more by fear than by consent, so they have many enemies.