During the episode Gil always rejects Edgar's advances and/or believes it's just a joke when Edgar plays it off as one. while highly unlikely that Phylice would agree to it, open marriages and polyamory exist. As much as Gil kinda wanted to, I'm convinced he never actually did anything with Edgar (because Gil admits to still being a virgin on his day 7), so I think trying to have a relationship with Walter is fine because he and Edgar were never together, just friends and Edgar was flirty. Gil even implies Edgar is like that with everyone, though there are hints Edgar is actually serious when flirting with Gil. that doesn't mean Gil ever did anything with him.