This is also true for kriah (rending the garment), SA YD 340:5 writes one should perform kriah when being present when a Jew dies. The Rema adds
one who was in the habit of committing sins, is not mourned
for; and so much the more for one who is an apostate in respect of
idolatry [...] and some say that we observe no mourning rites [for
him], and this is the [accepted] fundamental principle.
However nowadays the definition of one who one doesn't mourn for is much more restricted.
R Chaim Binyamin Goldberg (Mourning in Halacha, p. 84) writes
In recent generations, many authorities have ruled that most
non-observant Jews do not fall under the category of mumar (a person
who denies the existence of God or the validity of a mitzva), even
though their beliefs and practices would seem to be those of a
mumar. In this view, non-observant Jews who were raised in secular society and not taught traditional Jewish practices have the halachic
status of anusim (people who were coerced to transgress), or
tinokos shenishbu (children who were taken captive and raised in a non-Jewish atmosphere), who are not considered mumarim.
Since this is a complex issue for which there is no general rule, a
competent halachic authority should be consulted.
I have heard the same from R Binyamin Tabady when I asked him the question (before seeing the book).