\documentclass{report}
\usepackage[linktoc=all]{hyperref}
\usepackage{titlesec}
\usepackage{titletoc}

\titleformat{\section}
  {\normalfont\Large\bfseries}{}{1em}{}
\titleformat{\subsection}
  {\normalfont\large\bfseries}{}{1em}{}
\titlecontents{section}
  [1.5em] {}{}{}
  {\titlerule*[1em]{.}\contentspage}
\titlecontents{subsection}
  [3.8em] {}{}{}
  {\titlerule*[1em]{.}\contentspage}

\hypersetup{
    citecolor=black,
    filecolor=black,
    linkcolor=black,
    urlcolor=black
}

\begin{document}
\tableofcontents
\chapter{test}

Test text
\newpage
\section{A section}

Lorem Ipsum
\newpage
\subsection{This link is correct}

\end{document}
