I would like to add my own two cents in here as somebody who works in a "toxic" area.
- In essentially all areas of mathematics there is both good work and bad work being done. Mainstream areas, however, tend to have a larger number of people doing good work (because, after all, few people are willing to spend 6-10 years attacking the hardest problem in an unpopular field when almost nobody will pat you on the back when you are done). Because of that nobody will simply dismiss you out of hand for working in, say, Number Theory despite the fact that there are also plenty of bad papers published in this area.
On the other hand, unfashionable areas also have good people trying to do good work who publish in very good journals. If you want to go that route you must be very dedicated and be prepared to have papers rejected by good journals without being sent to a referee and to not get job interviews because you work in area X. So you should only work in such an area if you love the mathematics.
On the other hand publishing a paper in a toxic area in a top journal can sometimes have the opposite effect: people realize that publishing in a top journal in certain areas is more difficult than others and will say wow he/she published in ((insert journal name)) on ((insert unfashionable area)), he/she must be doing good work.
So the point is good work in a toxic area can still end up receiving recognition if you work hard enough to get it recognized.
- However, you seem to indicate that it is not such good work in a toxic area that is at issue. Here the question becomes more complicated because there is a scientific issue and a human issue. Suppose that at a conference I spend an evening discussing mathematics with a colleague and we make progress on some problem he/she is interested in and he/she wants to make a paper out of it. Then there is a human question. If I tell this person that I only want to be thanked and not be an author, they might be offended. Maybe this person is a friend or for some other reason I don't want to offend them. The scientific vs. human issue can be complex. The more senior you are the less effect having a paper in a weak journal is because people won't really notice it. Nonetheless at any point in one's career people's feelings have importance, too. I don't have any good answer on how to balance this aspect.
- Grad students often underestimate the difficulty of a problem they have solved without seemingly having done much. For instance, there is the following famous story in computer science. It was long an open problem whether non-deterministic space complexity classes were closed under complement because the obvious approach to recognize the complement of a language does not preserve space complexity. People in the area generally believed that space complexity wasn't preserved by complementation. The story goes that a certain grad student (somebody at MO probably knows who and can edit this) arrived late to class and thought that the prof was asking a homework problem rather than presenting an open problem and came up with a clever, but elementary proof that space complexity classes were in fact closed under complement. Sometimes people coming with a fresh viewpoint and with training in other areas of math see things that nobody in the area saw and although the arguments seem like elementary observations, they may be important.