The thread of their relationship continues in Season 5, with Castle and Beckett trying (and mostly failing) to conceal their relationship from their co-workers – not simply because of office gossip, but the threat of a misconduct charge being levied by the ever-watchful Captain Gates. In episode 5.04 (Murder, He Wrote), Ryan accidentally stumbles on the truth while interrogating a suspect, but chooses to keep the truth to himself and respect their privacy. Lanie and Esposito learn the truth in the following episode when Castle was framed for murder (Ryan told Esposito and Beckett told Lanie so that they were aware of the fact that their background research would expose Castle's contact with Beckett outside of case-related matters). In the Season 5 episode "Still", Captain Gates reveals that she has known about the relationship and has kept quiet since to maintain "plausible deniability", i.e. she cannot report the relationship because she hasn't personally witnessed any behavior to suggest a relationship and is happy to keep up the plausible deniability so long as the pair remain professional on the job.