I suspect any issues will relate to "probable cause" as to how the government concluded (in the first place) that the "foreigner" (could be a US citizen overseas, in a global sense) is apt to engage in a conversation that represent a foreign intelligence interest. If it reached that conclusion in the first place based on secret surveillance, the case is a harder one to get past a judge. It resembles "precrime," where any and all surveillance is justified, based on the "successes" where surveillance is the only activity that creates the reasonable suspicion.
A couple points. First, what "action" is used to head off the attack? Arrest and incarceration? Liquidation? So far, quite a few of the terrorists are in the court system - not saying they should be, but once there, the method of obaining evidence and probable cuase matters.
Second, beware the "ends justify the means" line of argument. Is anything okay, if it's for the purpose of heading off an attack?
But so long as these wiretaps were used purely in a national security capacity, then I suppose all these other legal landmines are avoided.
Instead of "national security," the law uses "foreign intelligence information." The President has total power relating to foreign intelligence. SCOTUS, in the Kieth case, had -really negative- comments about the Presindet justifying surveillance based on "national security."