Most soaps will expire after two to three years, but if it still lathers, it should still work. Some soaps may expire sooner if the essential oils or fragrances get moldy or rancid.
Obviously, if your soap is moldy or smells rancid, it’s time to get a new bar.