This is solution to wrap a paragraph around a box flushed to the right (or left) margin based on my previous answer.
No other packages were needed.
The command \InsertBox was defined, with 4 parameters.
\InsertBox[<l or r (default} >]{<box content>}{<box width>}{<text to be shaped>}
- (optional) where to place the box in the text area:
r or l (r,right,
is the default);
- content of the box;
- desired box width;
- paragraph to be shaped.
See wrapping without extra packages

\documentclass{article}
\usepackage{kantlipsum}% dummy text
%***************************************************************************************************
\newlength{\AboveSkipbox}
\setlength{\AboveSkipbox}{0.7\baselineskip} % above space <<<<
\newlength{\Sidesepbox}
\setlength{\Sidesepbox}{1.5em} % side space <<<
\newlength{\BoxHeight}
\newlength{\ParHeight}
\newlength{\FirstIndent}
\newlength{\FigureBoxWidth}
\newlength{\FigIndent}
\newsavebox{\mybox}
\newsavebox{\tmpbox}
%% From https://tex.stackexchange.com/questions/127504/more-condensed-version-of-parshape
\makeatletter
\let\SavedIndent\parindent
\let@afterindentfalse@afterindenttrue
@afterindenttrue
\def\newparshape{\parshape@npshape0{}}
\def@npshape#1#2#3{\ifx\#3\expandafter@@@npshape\else\expandafter@@npshape\fi
{#1}{#2}{#3}}
\def@@npshape#1#2#3#4#5{%
\ifnum#3>\z@\expandafter@firstoftwo\else\expandafter@secondoftwo\fi
{\expandafter@@npshape\expandafter{\the\numexpr#1+1\relax}{#2 #4 #5}{\numexpr#3-1\relax}{#4}{#5}}%
{@npshape{#1}{#2}}}
\def@@@npshape#1#2#3{#1 #2}
\def\SetFirstIndent{\if@afterindent\FirstIndent\SavedIndent\else\FirstIndent\z@\fi}
\makeatother
\newcommand{\nlines}[1]{\the\numexpr#1/\baselineskip +1 \relax}
\newcommand{\TypesetBox}[1]{\makebox[\linewidth][#1]{\raisebox{\dimexpr-\ht\mybox-\AboveSkipbox\relax}[0pt][0pt]{\usebox{\mybox}}}}
\newcommand{\TypesetTextShortLong}[1]{%
\hspace*{\parindent}
\ifdim\dimexpr\ht\tmpbox+\dp\tmpbox<\dimexpr\ht\mybox+\dp\mybox+2\baselineskip\relax%short
\hspace{-\parindent}\usebox{\tmpbox}\vspace{\dimexpr\ht\mybox+\dp\mybox+\AboveSkipbox-\ht\tmpbox-\dp\tmpbox\relax}
\else%long
#1\fi
}
\newcommand{\MakeFigureSpace}[1]{%
\ifx#1l% left
\setlength{\FigIndent}{\FigureBoxWidth}
\else% right
\setlength{\FigIndent}{0pt}
\fi
}
\newcommand{\InsertBox}[4][r]{%
\SetFirstIndent%
\setlength{\FigureBoxWidth}{\dimexpr#3+\Sidesepbox\relax}
\sbox{\tmpbox}{\parbox[t]{\dimexpr\linewidth-\FigureBoxWidth\relax}{\hspace{\FirstIndent}#4}}
\sbox{\mybox}{\fbox{\parbox{#3}{#2}}}%
\MakeFigureSpace{#1}% Figure Indent = \parindent or Fig Box width
\vspace{-\baselineskip}
\hspace{\dimexpr-\FigIndent-\parindent\relax}\TypesetBox{#1}
\newparshape% shape paragraph text
{\nlines{\dimexpr\ht\mybox+\dp\mybox+\baselineskip\relax}}{\FigIndent}{\dimexpr\linewidth-\FigureBoxWidth\relax}%
{1}{0pt}{\linewidth}\
\TypesetTextShortLong{#4}
}
%***************************************************************************************************
\begin{document}
\InsertBox{Expected on the right 1}{0.3\textwidth}{\kant[2]}
\kant[9]
\InsertBox[l]{\bfseries \large As I have shown elsewhere, Aristotle tells
us that the objects in space and time, in the full sense of these
terms, would be falsified.}{0.4\textwidth}{\kant[4]}
\end{document}
\mytextand\begin{wrapfigure}second and third boxes are shown on the right. (I'm using pdflatex with a yesterday updated miktex system) – Ignasi Nov 18 '21 at 18:19