But "they knew" -- in the sense that they knew
in advance -- is a meaningless concept when talking about the Prophets. To them, all times are one. It's all right now to them. So there is no "when did they know it," there's just "what did they know."
Besides, what are you suggesting? That they should've stopped the fleet earlier? The fleet wasn't coming through the wormhole earlier. They acted at the only point where that particular action was relevant.