Permissibility of stocks

Salamu aleikum. I want to invest in stocks but i have some doubts about the permissibility. Even with stocks considered halal or “shariah compliant,” there is still the fact that these companies are involved in riba, such as keeping there money in banks which take interest. As a partial share holder I would be considered taking interest as well. I understand there are many opinions by many scholars on this issue, i just want some further clarity as I am new to this and although I need to invest for my future, i want to make sure i don’t do anything to jeopardize my future in the akhirah. All input is greatly appreciated. Jazakum Allahu khairan
Attached is a link to a fatwa, where i believe the stocks encouraged by IFG mostly fall into category #3 in the link. (Companies whose business is halal but keep interest-bearing accounts in the bank, or they are financed by means of riba-based loans from banks or from people in the form of stocks.)
Please correct me if i am wrong.