Q. If someone takes a hot shower on a cold day or goes to a nice warm Mikva, can he thank Hashem in his mind as he always does for the pleasure received, while in a shower or Mikva?
A. On question 627 regarding if the mitzvah of loving Hashem since it is in essence only a feeling and emotion of the heart, and is similar to fearing Hashem, if those feelings, without images or added thoughts, permitted when one is in a bathroom or mikva. we wrote: " Chashukei Chemed (Brochos 24b) debates the issue, and wants to prove from Mishna Berura (85: 6) that opines one should engage while in the bathroom on thoughts pertinent to one’s business or work, to avoid thinking about divrei kedusha, that indeed thinking about Hashem’s presence may not be permitted, however, he decides otherwise. He also quotes Sefer Chasidim (545); In all places acknowledge your Maker, even in those you cannot think the words of Torah.
Horav Shlomo Miller Shlit’a pointed to a Chochmas Shlomo (O.H. 85: 2) that maintains one should remain conscious and aware of Hashem’s presence even when being in a bathroom, to comply with Shivisi Hashem lenegdi tamid, “Keep Hashem before you always.” Chochmas Shlomo adds that this applies even to the dreams one has.
The Rov maintains that feelings of love or fear of Hashem’s presence are certainly not only permitted but advised, as they belong to the six constant mitzvos. The Rov added that musar on midos and planning thoughts for performing mitzvos and similar are permitted in those unclean locations."
On question 2423 we added: Nachal Eshkol explains that this is the intention of Shir Hayichud when saying Kol Tinofes or no dirt can sully You. Eretz Zvi (1; 62) maintains that we recite modeh ani when waking up and addressing Hashem even with unclean hands and body. Other Poskim agree (Mishne Sochir 2: 23, Lev Avrohom 53, etc.
However, different Poskim disagree and maintain that one should not think of Hashem’s presence when in impure locations. (Lehoros Nossan 1:1, Tzitz Eliezer 13: 1, etc).
Horav Shlomo Miller’s Shlit’a opinion is that it is permitted."
In our case, if it is only basically a short thanking feeling of 'Hakaras Hatov," that a person has in his heart and mind directed to Hashem for the pleasure one is receiving, it is permitted.
Rabbi A, Bartfeld as advised by Horav Shlomo Miller and Horav Aharon Miller Shlit'a