In Grand Budapest Hotel, when Gustave, Zero and Agatha return to the hotel to retrieve the painting the hotel has been occupied by the Zig Zag division. Only Agatha enters, Gustave and Zero wait in a lorry outside the building. A car drives up, Dimitri leaves it and enters the hotel. Zero and Gustave know that he will recognize Agatha and thus enter the hotel themselves to rescue her.
How did they know that Dimitri will recognize her?
Of course she is easily recognizable once seen even on photo, that is the plot function of the grotesque birthmark in the form of Mexico over half of her face. Dimitri has seen her photo in the files that Jopling acquired to find the people that helped Gustave escape from the prison. So it is indeed possible that Dimitri will recognize her as one of the persons that helped Gustave earlier.
But how did Gustave and Zero know about this immediate danger? I don't think it is likely that they know Jopling was specifically after her, acquired the photo from the office of servitude and labour, organized a file, and Dimitri read that file. And if he would not recognize her they create massive additional risks by being recognized themselves.