The I love you coffin isn't meant for Molly
Eurus said someone was going to die, Sherlock deduced it must have been Molly. But after he made her say ‘I love you’ it was revealed she wasn’t in actual danger. So the coffin couldn’t have been for her, she was never going to die, no matter what happened.
Then who is going to die if Sherlock doesn’t make them say the 'code’? John.
John, who is going to die if he fails to revive himself like Sherlock did in HLV, if he fails to realize he’s in love with Sherlock, that he actually has something to live for (a life with Sherlock an Rosie, back in Baker Street).
The only way he could realize this would be for Sherlock to say it 'like he means it’ to him first.