Following this example I created a command to check, if the bold font is currently selected.
This definitely used to work with fontspec some time ago (with TeXlive2018, if pdf-metadata is to be trusted), but not anymore (just ran tlmgr on my TeXlive2020 installation), as the following MWE shows:
%!TEX program = lualatex
\documentclass{scrbook}
\usepackage{etoolbox}
\usepackage{hyperref}
%-- Font setup
\usepackage[euler-digits]{eulervm}
\usepackage[no-math]{fontspec}
\defaultfontfeatures{Extension=.otf}
\setmainfont{XCharter} % <-- COMMENT THIS LINE!
%-- IfBold Command
\makeatletter
\newcommand*{\IfBold}{%
\ifx\f@series\my@test@bx
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
\fi
}
\newcommand*{\my@test@bx}{bx}
\makeatother
%-- Define a command for K-theory
\newcommand{\Kay}{\IfBold{\ensuremath{\mathbold{K}}}{\ensuremath{K}}}
\robustify{\Kay}
\newcommand{\K}{\texorpdfstring{\Kay}{K}}
\begin{document}
\section*{I like \K-Theory}
This is the regular \K.
\textbf{This is \IfBold{bold}{non-bold} text.}
This is \IfBold{bold}{non-bold} text.
\end{document}
Is this a newly introduced bug or am I missing something?

\DeclareFontSeriesDefault[sf]{bf}{b}and to test for b:\newcommand*{\my@test@bx}{b}, but I will discuss a more generic solution to test for "bold context". – Ulrike Fischer May 14 '20 at 12:40