Let $\mathcal{C},\mathcal{D}$ two $\infty$-categories and $f:\mathcal{C}\to\mathcal{D}$ and $g:\mathcal{D}\to \mathcal{C}$ two functors.

Recall (HTT.5.2.2.7) that a natural transformation $u:1_{\mathcal{C}}\to gf$ is a *unit transformation* if the natural transformation
$$(\ast)\qquad\mathrm{Map}_{\mathcal{D}}(f-,-)\to \mathrm{Map}_{\mathcal{C}}(gf-,g-)\xrightarrow{u^*}\mathrm{Map}_{\mathcal{C}}(-,g-)$$
is an equivalence.

> **Theorem** A natural transformation $u:1_{\mathcal{C}}\to gf$ is a unit transformation if and only if there is a natural transformation $e:fg\to 1_{\mathcal{D}}$ satisfying the triangular identities.

*Proof:* 

Let us first show that if such an $e$ exists, then the natural transformation $(\ast)$ is an equivalence. Indeed we will show that the natural transformation
$$(\ast\ast)\qquad\mathrm{Map}_{\mathcal{C}}(-,g-)\to \mathrm{Map}_{\mathcal{D}}(f-,fg-)\xrightarrow{e_*}\mathrm{Map}_{\mathcal{D}}(f-,-)$$
is an inverse. Indeed, if $l:fc\to d$ is an arrow in $\mathrm{D}$, the transformation $(\ast)$ sends it to $gl\circ u_{gd}$. Then, $(\ast\ast)$ sends it to
$$e_{d}\circ f(gl\circ u_{gd})\cong e_{d}\circ fgl \circ fu_{gd}\cong l\circ e_{fc}\circ fu_c \cong l$$
where the second equivalence is the naturality of $e$ and the third is one of the triangular identities. So $(\ast\ast)$ is a left inverse of $(\ast)$. The dual proof (using the other triangular identity) implies that it is a right inverse too, so that $(\ast)$ is an equivalence.

Let us now prove the other direction. if $(\ast)$ is an equivalence, in particular, the map
$$\mathrm{Map}_{\mathcal{D}}(fg-,-)\cong\mathrm{Map}_{\mathcal{C}}(g-,g-)$$
is a natural equivalence. By taking ends, there is an equivalence of the space of natural transformations
$$\mathrm{Nat}(fg,1_{\mathcal{D}})\cong \mathrm{Nat}(g,g)$$
Let $e:fg\to 1_{\mathcal{D}}$ be the natural transformation corresponding to $1_g:g\to g$ under this equivalence. I claim that this satisfies the triangular identities.

In fact, for every $d\in\mathcal{D}$, the arrow $e_d$ has been chosen so that there is an equivalence
$$(ge_d)\circ u_{gd}\cong 1_{gd}$$
naturally in $d$. So one triangular identity is satisfied. On the other hand, arguing as in the previous direction, this implies that $(\ast\ast)$  is a right inverse of the map $(\ast)$. Since that was an equivalence, it must be a left inverse too, Choosing $l=1_{fc}$, this shows $e$ satisfies the second triangular identity.