"I've shaved this morning" has the verb in present perfect tense ("I've shaved"). "I'd shaved that morning when my friend walked in" would be past perfect ("I'd shaved"). As the link states, using the present perfect is fine with a specific time like "this morning" as long as it is still the morning.
Present perfect is used when an action begun in the past has a connection to the present. There can be many different ways to connect an action to the present.
The action can still be ongoing: "I've worked out for 40 minutes, and I'm going to keep going for another 20 minutes".
The action can be completed right around the present time: "I've finished my cup of coffee, so let's go out."
You can express if you have ever done something in your life (or some timeframe) up until now: "I've flown a plane before; I did it once 10 years ago."
As you can see, there is no singular rule that says "this type of time expression will always be right/wrong with present perfect". You just have to have a connection to the present.
So, applying this more specifically to your concerns:
- "I've shaved this morning" when it is the morning = correct
- "I've shaved this morning" when it is the evening = incorrect
- "I've shaved in the morning" = incorrect if you do not intend any connection to the present, but correct if your meaning is "in my life up to now, I have shaved in the morning at least once".
In summary, the sentence is not incorrect, and the construction is, in fact, the present perfect.