When Phil Coulson, Leo Fitz, and Robbie Reyes were trapped in the interdimensional space between Earth and Hell, May was insistent that the key to rescuing them was in the Darkhold. She showed the book to Holden Radcliffe, who upon skimming for a few seconds, stopped reading the book, saying it was too much to handle. His LMD, Aida asked to read the book and she was able to find a way to open a gate to save Coulson and Fitz, and later Reyes from being pulled into Hell.
However, the brief moment of scanning the book was enough to corrupt Radcliffe and, upon hearing Melinda May was going to retrieve Aida to help against Eli Morrow, gave Aida a specific command called Sunset Protocol.
Upon arriving, Melinda May was completely unaware of Aida's intentions, and the LMD was able to drug and knock out May. While unconscious, Aida kept the agent drugged as she programmed the Melinda May LMD with May's memories, so it would believe that it was the genuine Melinda May, and the two robots went to aid in stopping Eli Morrow.
The May LMD was complete unaware of her programming, but was set to grab the Darkhold for Radcliffe once the opportunity presented itself. Meanwhile, in order to keep May passive, Radcliffe and Aida worked on improving the Framework to keep her mind occupied from trying to escape the simulation and waking up.