my scenario: my internal users navigation shows up a list of companies(document library) which they can use without any restrictions. But for my external users only a certain company is shared to them and they are only allowed to view that company files.now the navigation for my external users need to show those companies shared with him AND IF ONLY ONE company is shared with him,the navigation need to show the inner contents(document sets) of the document library of that company directly.(THIS WILL BE IMPLEMENTED THROUGH CSOM)
SharePoint will do this out of the box through security trimming. You can create permission groups and give access as appropriate to the external users. The Users (Internal or External) won't see the link on the navigation if they don't have access to the particular document library / page (or any other apps).
Saving them one click to reach to the document set directly instead of the document library link provided, I don't think it is possible OOTB.
You might want to consider creating a page for external users (with restricted permissions) and placing the document library or document set directly on the page.