Union and With Clause SubQuery Oracle

I need immediate help in solving my problem before using in production:

Am using below SQL in Oracle11g

With sub_query1 as (select t1.column1, t2.column2, t1.id from table1 t1
inner join table2 t2 on t1.id = t2.id )
SELECT t3.column3 s1.* FROM sub_query1 s1 
INNER JOIN table3 t3 ON t3.id=s1.id
union
SELECT t4.column4 s1.* FROM sub_query1 s1 
INNER JOIN table4 t4 ON t4.id=s1.id;

This was working when I was using as is, but when add one subquery before SUB_QUERY1 it is not working, it is just returning 0 rows without any error:

With 
main_sub_query as (select ta.id from tableA ta)
--second subquery
, sub_query1 as (select t1.column1, t2.column2, t1.id from table1 t1
inner join table2 t2 on t1.id = t2.id 
inner join main_sub_query mq ON mq.id=t1.id
)
SELECT t3.column3 s1.* FROM sub_query1 s1 
INNER JOIN table3 t3 ON t3.id=s1.id
union
SELECT t4.column4 s1.* FROM sub_query1 s1 
INNER JOIN table4 t4 ON t4.id=s1.id;

When I remove the union and later part it is returning data, not sure what is the issue.