To obtain reliable results for new scenario, I think that it is necessary to have a column that orders the rows (for example a Created with distinct time part).
The next variation relies on default ordering:
;
with T1 as
(
select *,
row_number() over (partition by issue_id order by Created) i
from #temp
),
T2 as
(
select *,
row_number() over (partition by issue_id, Created order by i desc) j
from T1
),
T3 as
(
select *, cast(isnull(to_string, '') as varchar(max)) as final_string
from T2
where i = 1
union all
select T2.*,
cast(stuff((select ',' + s from (
select value from string_split(T3.final_string, ',')
except
select * from (values (T2.from_string)) d(s)
union all
select * from (values (T2.to_string)) d(s)
) d(s) for xml path('')), 1, 1, '') as varchar(max))
from T2
inner join T3 on t3.issue_id = t2.issue_id and T3.i+1 = T2.i
)
select issue_id, Created, final_string
from T3
where j = 1
order by issue_id, i
Results:
/*
issue_id Created final_string
420145 2018-06-13 EPC-Management
420145 2018-11-18 L3-7,L2-4
420145 2018-11-21 L2-4,Management
420145 2018-11-25 L2-4,XM
420145 2018-12-10 XM
420145 2018-12-23 XM,L2-4
*/