I don't think your dwarf gourami will actually swallow a strand of hair. In any case, if he poops it out, all will be fine. Hair is organic and will eventually move out of his digestive system.
Stringy poop on the other hand, may be symptoms of a stressed fish. You may need to see how you can make it more comfortable. Perhaps a bit more floating plants for him to hide under?
Cheers,
Bookmarks