My question is regarding project based jobs. Most of the time when we are on projects we get projects from multiple clients. For example
Case 1 :
Abdullah got employed by a private consultancy (XYZ) as a consultant on a project i.e. for a bank (say Citi-bank) to work in IT , on the other hand this bank doesn't take any of the bank's work with him but they hired him for their clients and the project he is working on is of (Macy's (retailer, clothers, perfume), USPS (Postal service)) but not on anything of Bank (Citi-bank).
Now in Abdullah's case, Macy's and USPS are paying Citi-bank for the work he is doing for them, Citi takes some percentage and pays to the Private Consultancy ( XYZ), now this XYZ takes some percentage and pays Abdullah whatever pay was agreed by both parties.
So in short here, xyz hires Abdullah for Citi-bank and Citi-bank hired him for working for Macy's and USPS, the job deal has been between XYZ and Abdullah. Where XYZ pays him and its just a consultancy who hires professionals for other companies but pays them under XYZ.
Case 2 :
Imran working for xyz but some insurance company.
Now XYZ has another consultant whom it pays for working for an Insurance company (AAA). The work again doesn't involve any sort of collecting or counting interest or doing accounting, but its all behind the scene work developing softwares, upgrading their servers without knowledge of any data or applications on the server, say UNIX work where he runs just commands without working directly for them.
But, but again he doesn't work for any project of this company (AAA), rather AAA hired him just to make some money by making him work on other projects. so he is now working on a project that AAA assigns it from Gambling company (LX) for 3 months.
So now LX pays AAA for Imran, then AAA takes its share/percentage and pays to XYZ for the work, finally XYZ pays Imran as the agreed Salary between the 2. case 2b) then AAA assigns him on another project this time for a Hospital. now Hospital pays for similar work to AAA for Imran, and AAA pays to XYZ and XYZ to Imran.
Considering the above cases 1, 2a and 2b, Abdullah and Imran are not working directly for any financing company or bank, since they are project based and Imran can get any client project every 3 months, but the paying company or the salary agreement is between XYZ and the worker, here XYZ is clean in terms of kind of work it does.
So getting hired for XYZ and working whatever comes our way is halal or what stage of halal or haram, or mushbooh it is?