Prosecutors said that Al Bahnasawy also communicated with an undercover agent posing as an ISIS sympathizer about wanting to "shoot up concerts cuz they kill lots of people."
Seems to me that was the start of how the undercover agent posing as an ISIS sympathizer was ultimately identified - and from that moment on, his life and the lives of 58 people in the audience were forfeit.
Your analysis is the only explanation that makes any sense. Nothing else makes even an atom of sense.