As pointed out by our OP user772744 in the text of the question
itself,
$f'(z) = 0 \tag 1$
for
$z \in D \tag 2$
implies
$u_x = u_y = v_x = v_y = 0 \tag 3$
in $D$ as well; that is
$\nabla u = \nabla v = 0 \tag 4$
in $D$.
Now, since $D$ is a connected set in $\Bbb C$, it is path connected; see this wikipedia entry. And since $D$ is a path connected set in $\Bbb C$, it is $C^1$ path connected, see this question and its answers; that is, any two points
$z_1, z_2 \in D \tag 5$
may be joined by a $C^1$ path
$\gamma:I = [0,1] \to D \tag 6$
with
$\gamma(0) = z_1, \gamma(1) = z_2; \tag7$
such a path $\gamma(t)$ may of course be viewed in either of two ways, as
$\gamma:I \to \Bbb C, \tag{7.1}$,
with
$\gamma(t) = x(t) + iy(t), \tag{7.2}$
or as
$\gamma:I \to \Bbb R^2, \tag{7.3}$
with
$\gamma(t) = (x(t), y(t)); \tag{7.4}$
for any such points $z_1$, $z_2$ and such a real path $\gamma(t)$ as in (7.4) we have the real integral formula
$u(z_2) - u(z_1) = u \circ \gamma(1) - u \circ \gamma(0) = \displaystyle \int_{z_1}^{z_2} \dfrac{d(u \circ \gamma)(t)}{dt} \; dt$
$= \displaystyle \int_{z_1}^{z_2} \nabla u \cdot \gamma'(t) \; dt = \int_{z_1}^{z_2} 0 \cdot \gamma'(t) \; dt = 0, \tag 8$
where
$\gamma'(t) = (x'(t), y'(t)), \tag{8.1}$
yielding
$u(z_2) = u(z_1); \tag 9$
likewise,
$v(z_2) = v(z_1); \tag{10}$
that is, $u$ and $v$ are constant in $D$; hence, $f(z)$ is constant as well. $OE\Delta$.
Note Added in Edit, Sunday 27 December 2020, 6:35 PM PST: The above demonstration takes its cue from our OP user772744's observation that (1) implies (3); that is, it reduces the problem to integrals of the form (8) which compute $u(z_2) - u(z_1)$ and $v(z_2) - v(z_1)$ separately. It is of course possible to work directly from (1):
$f(z_2) - f(z_1) = \displaystyle \int_{z_1}^{z2} f'(z) \; dz = \int_{z_1}^{z2} 0 \;dz = 0, \tag{11}$
where now $\gamma(t)$ is of the form (7.2), so that
$\gamma'(t) = x'(t) + iy'(t), \tag{11.1}$
and
$dz = \gamma'(t) \; dt. \tag{12}$
End of Note.