A unified algebraic underpinning for the Hahn polynomials and rational functions