I re-watched the episode today to try to make sense of some of the South Africa stuff that I didn't understand, and I picked up on something about Martha that I didn't realize the first time:
The FBI brings in some kind of "Internal Affairs" type guy to investigate the bug, and he mentions that its possible that Gad planted the bug himself. That's when Martha probably remembers that Phil's own story to her was that HE was the Internal Affairs guy investigating Gad. Since the real Internal Affairs guy is investigating who planted the bug, Martha figures out that Phil has been lying about who he is.
Because if Phil had been telling the truth, that guy would have already known about the bug.