All perfect praise be to Allah
The situation described in is absolutely a wrong thing by X, but their can be circumstances where X is doing the right thing in some parts.
Let's analyze this story in parts.
X knows B who is alcoholic and beats his wife, now he does not report it to any one "who could have taken some action"...
Assuming by someone here it means some relative or elder of the neighbourhood who have some influence on B, In this part X is wrong, why? Because, helping the muslim is part of the faith. Though first reason would be amar bil maroof wa nahi anil munkir which is a duty:
"The Believers, men and women, are protectors one of another: they
enjoin what is just, and forbid what is evil: they observe regular
prayers, practice regular charity, and obey Allah and His
Messenger..." (at-Tawba, 9/71)
Here X didn't performed his duty. And second reason not helping oppressed and oppressed muslim brother, as hadees states:
Narrated Anas: Allah's Apostle said, "Help your brother, whether he is
an oppressor or he is an oppressed one. People asked, "O Allah's
Apostle! It is alright to help him if he is oppressed, but how
should we help him if he is an oppressor?" The Prophet said, "By
preventing him from oppressing others."
Here X had to help that couple, which he didn't. So, obviously in this part, X is not following at-least 2 commandments of islam.
Than, next part: Eventually, B's wife is killed by B in a domestic argument. B is later tried in court, but because there are not enough witnesses, B is found innocent. X chooses not to testify.
Now here is a BIG problem...
Islam orders believers to testify what they know even without being asked for it.
وَلَا تَلْبِسُوا الْحَقَّ بِالْبَاطِلِ وَتَكْتُمُوا الْحَقَّ وَأَنتُمْ
تَعْلَمُونَ
And cover not Truth with falsehood, nor conceal the Truth when ye know
(what it is). Quran 2/42
وَلَا تَكْتُمُوا الشَّهَادَةَ ۚ وَمَن يَكْتُمْهَا فَإِنَّهُ آثِمٌ
قَلْبُهُ ۗ وَاللَّهُ بِمَا تَعْمَلُونَ عَلِيمٌ
And do not conceal testimony, for whoever conceals it - his heart is
indeed sinful, and Allah is Knowing of what you do. quran 2/283
There are many other verses and references for this issue, for now these 2 ayahs are clear and conclusive, not giving testimony when you know it can give justice to someone, is a big sin.
Now last part:
B later on marries someone else, who X knows, but X still doesn't tell her about B's character.
Firstly, it was X's duty to let the other person know about the character of B before marriage, because it is like saving someone from being oppressed, because B is likely to do same again. If he knew all the happenings about marriage/proposal etc and he could have easily told them, it was his duty of the category of well wishing/helping muslims which is an integral part of islam.
Secondly, now after the marriage if their life is ok now, and there's nothing like the first one, like domestic violence or anything, in short they are having normal married life, than its better not to tell his wife anything. But, if situation is like before, and violence has been started, he can tell her seeing all the scenario and results. With the same reason of well wishing for muslims.
PS: I am not a mufti, still if i was X, i was on this stage i would have testified now on this stage, and had reopened the case. Because i think its better to clear your mistakes rather than having sinful heart for the rest of the life and for the akhirah. But it depends on the situation anyway.
Allah knows best