Try this:
Lua Code:
hooksecurefunc("TextStatusBar_UpdateTextStringWithValues", function(statusFrame, textString, value, valueMin, valueMax)
if statusFrame == PlayerFrameHealthBar or ((statusFrame == TargetFrameHealthBar or statusFrame == FocusFrameHealthBar) and not UnitIsDeadOrGhost(statusFrame:GetParent().unit)) then
local formattedValue = (value > 1e6 and ("%.2fM"):format(value / 1e6)) or (value > 1e4 and ("%.0fk"):format(value / 1e3)) or value
textString:SetFormattedText("%s (%.0f%%)", formattedValue, value * 100 / valueMax)
end
end)
I had to rename all the variables and reformat the code because the one-letter names and strange space-saving arithmetic operations made it very difficult to read.