(Rabbi Wallerstein explained this story in terms of addiction and it makes quite a lot of sense.)
The Kav Hayashar was written in 1705 by Rav Tzvi Hirsch Kaidanover and I think first published in Russia because the author mentions his mentor and teacher, Rav Yosef ben Rav Yehudah Yudel, who was av beis din and rosh yeshivah of Minsk, then later passed away in Dubna.
Anyway, here is an encouraging excerpt from Chapter 23 of Kav Hayashar:
וְלֹא עוֹד שֶׁהַקָּדוֹשׁ בָּרוּךְ הוּא מְזַכֶּה אוֹתוֹ לְמִי שֶׁיִּתְפַּלֵּל אֵלָיו בְּלֵב שָׁלֵם, שֶׁהוּא מְזַכֶּה אֶת אֲחֵרִים, אִם רוֹאֶה שְׁאָר בְּנֵי אָדָם, וּמִכָּל שֶׁכֵּן קְרוֹבָיו אוֹ בָּנָיו, שֶׁהוֹלְכִים בְּדֶרֶךְ לֹא תָּמִים, שֶׁצָּרִיךְ לְהִתְפַּלֵּל עָלָיו תְּחִלָּה שֶׁיִּתַּמּוּ חַטָּאִים וְיַחְזְרוּ בִּתְשׁוּבָה. וְאַחַר כָּךְ אִם חַס וְשָׁלוֹם יִרְאֶה שֶׁלֹּא הוֹעִיל לִתְפִלָּתוֹ, יִרְאֶה לְהוֹכִיחָם, אוּלַי יִמְצָא עֵת רָצוֹן, שֶׁהַקָּדוֹשׁ בָּרוּךְ הוּא יִתֵּן בְּלֵב הָאֲנָשִׁים הַמּוֹרְדִים בּוֹ שֶׁיַּחְזְרוּ בִּתְשׁוּבָה, וְיִהְיֶה גַּם כֵּן לְנַחַת רוּחַ. שֶׁהַקָּדוֹשׁ בָּרוּךְ הוּא שׁוֹמֵעַ תְּפִלָּתוֹ לְהָשִׁיב לֵב הָרָשָׁע לַעֲשׂוֹת תְּשׁוּבָה.
Moreover, the Holy One Blessed is He grants the person who prays to Him wholeheartedly the ability to benefit others.
For instance, if someone observes that others, especially his own relatives and children, are headed in a bad direction, let him first pray that they leave off their sinning and repent.
Only afterwards, if he sees that his prayer did not help, let him rebuke them. Perhaps he will find a moment of favor when Hashem will agree to put it into the hearts of the rebellious to repent.
Then the one who prayed will also feel a sense of contentment that The Holy One Blessed Be He accepted his prayer to incline the heart of the evildoer to repent.
And also, in contrast to the modern approach, he advises praying wholeheartedly for your errant loved ones BEFORE engaging in practical efforts, like rebuke.
May Hashem answer all our prayers l'tovah.